-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
103 lines (95 loc) · 2.85 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
// entry: './index.js', // assumes your entry point is the index.js in the root of your project folder
// entry: {
// app: './src/index.js',
// print: './src/print.js'
// },
entry: './src/index.js',
output: {
// the target directory for all output files
// must be an absolute path (use the Node.js path module)
path: path.resolve(__dirname, "dist"), // string or __dirname
filename: 'bundle.js' // './bundle.js' assumes your bundle.js will also be in the root of your project folder or path.resolve(__dirname, 'dist')
// use 'bundle.js', run npx webpack src/index.js dist/bundle.js, then use '[name].js' to create bundle, and run again. Then switch back to bundle.js and a single entry point
},
// devtool: 'source-map', // or inline-source-map
// devServer: {
// contentBase: './dist',
// port: 9000
// },
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: {
presets: ['react', 'env', 'stage-3'] // needed to use stage-3 for destructuring and spread oper here for some reason
}
},
{
test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader', 'sass-loader' ] //must incl this for @import
},
{
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)(\?.*$|$)/,
loader: 'file-loader' // must include this for fonts
}
]
}
};
// IGNORE BELOW
// module.exports = {
// entry: {
// app: './src/index.js',
// print: './src/print.js'
// },
// devtool: 'inline-source-map',
// devServer: {
// contentBase: './dist'
// },
// plugins: [
// new CleanWebpackPlugin(['dist']),
// new HtmlWebpackPlugin({
// title: 'Development'
// })
// ],
// output: {
// filename: '[name].bundle.js',
// path: path.resolve(__dirname, 'dist')
// }
// };
// output: {
// // options related to how webpack emits results
//
// path: path.resolve(__dirname, "dist"), // string
// // the target directory for all output files
// // must be an absolute path (use the Node.js path module)
//
// filename: "bundle.js", // string
// // the filename template for entry chunks
//
// publicPath: "/assets/", // string
// // the url to the output directory resolved relative to the HTML page
//
// library: "MyLibrary", // string,
// // the name of the exported library
//
// libraryTarget: "umd", // universal module definition
// // the type of the exported library
//
// /* Advanced output configuration (click to show) */
// },