-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
76 lines (73 loc) · 1.99 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
var webpack = require("webpack");
var path = require("path");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const PATHS = {
src: path.join(__dirname, "./app"),
dist: path.join(__dirname, "./dist")
};
module.exports = {
mode: "development",
entry: {
app: [PATHS.src]
},
output: {
path: PATHS.dist,
filename: "bundle.js"
},
devServer: {
// contentBase: __dirname,
hot: true, // hot module replacement while application running
inline: true, // a script inserted in bundle for live reloading
progress: true, // output running progress to console.
disableHostCheck: true, //bypasses host checking
open: true, // open the browser after server started
stats: { colors: true }, //whether to output in the different colors
watchOptions: { poll: true }, //watching file changes use polling
// writeToDisk: true, //whether output bundle.js, vender.bundle.js, and index.html
// host: "0.0.0.0",
port: 7000
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "all",
enforce: true
}
}
}
},
resolve: {
extensions: [".js", ".jsx", "css"]
},
module: {
rules: [
{
test: /\.css$/,
loaders: ["style-loader"]
},
{
// transpile es6/jsx code to es5
test: /\.(js|jsx)$/, //which we are going to transform
exclude: /node_modules/, // which path should be ignored when transforming modules
// loaders: ["babel-loader"]
use: {
// "use": main rule's option
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"] //set default presets for Babel to consider which ES6 features it should transform and which not
}
}
}
]
},
plugins: [
new HtmlWebPackPlugin({
template: "./app/index.html",
path: PATHS.dist,
filename: "index.html"
})
]
};