-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.cjs
56 lines (51 loc) · 1.38 KB
/
webpack.config.cjs
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// const CopyWebpackPlugin = require('copy-webpack-plugin');
const CompressionPlugin = require("compression-webpack-plugin");
const webpack = require("webpack");
const resolve = dir => path.join(__dirname, dir);
const config = {
// where webpack starts to build the bundle. All other deps are imported from here.
entry: {
main: "./src/main.js",
worker: "./src/worker.js"
},
output: {
filename: '[name].js',
path: resolve("dist")
},
// customize the webpack build process.
plugins: [
new HtmlWebpackPlugin({
hash: true,
template: "./src/index.html",
filename: "index.html", //relative to root of the application
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new CompressionPlugin(),
],
resolve: {
fallback: {
"stream": require.resolve("stream-browserify"),
"util": require.resolve("util/"),
},
},
devServer: {
/** following two lines allow (less-secure) access from the Local network. */
allowedHosts: "all",
host: "0.0.0.0"
}
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
// note that by default, development mode uses evil eval.
// we must set the devtool explicitly to change this.
config.devtool = 'inline-source-map';
}
if (argv.mode === 'production') {
// do not enable source-map
}
return config;
};