-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
75 lines (67 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
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
const Dotenv = require('dotenv-webpack');
const path = require("path");
const {
CleanWebpackPlugin
} = require('clean-webpack-plugin');
const plugins = [new CleanWebpackPlugin(), new Dotenv()];
if (process.env.ANALYZE) {
plugins.push(new BundleAnalyzerPlugin());
}
const ENV = process.env.NODE_ENV || 'development';
const isProd = ENV === 'production';
const optimization =
isProd ? {
optimization: {
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendorOther: {
chunks: 'initial',
enforce: true,
name: 'vendor',
test: /node_modules\//
}
}
}
}
} : {}
module.exports = {
devtool: isProd ? "source-map" : false,
entry: "./src/index.js",
output: isProd ? {
chunkFilename: '[name].[chunkhash:8].js',
filename: '[name].[hash:8].js',
globalObject: '(typeof self !== \'undefined\' ? self : this)',
path: path.join(__dirname, "dist")
} : {
filename: "evolutionland.min.js",
globalObject: '(typeof self !== \'undefined\' ? self : this)',
path: path.join(__dirname, "dist")
},
watch: isProd,
watchOptions: {
poll: 1000,
aggregateTimeout: 2000,
ignored: /node_modules/
},
...optimization,
module: {
rules: [{
test: /\.(js|mjs)$/,
exclude: [/node_modules/],
loader: require.resolve("babel-loader"),
options: {
babelrc: true,
configFile: false,
compact: false,
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime",
]
}
}]
},
plugins
};