-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.babel.js
50 lines (46 loc) · 1.46 KB
/
webpack.config.babel.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
import webpack from 'webpack';
import { resolve } from 'path';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import LiveReloadPlugin from 'webpack-livereload-plugin';
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
import { getIfUtils, removeEmpty } from 'webpack-config-utils';
export default env => {
const { ifProd, ifNotProd } = getIfUtils(env);
return {
mode: ifProd('production', 'development'),
devtool: ifNotProd('cheap-module-source-map'),
resolve: {
alias: {
['~']: resolve(__dirname, 'src')
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
},
plugins: removeEmpty([
// new BundleAnalyzerPlugin(),
new MiniCssExtractPlugin(),
ifNotProd(new LiveReloadPlugin({ appendScriptTag: true })),
new webpack.EnvironmentPlugin({
NODE_ENV: ifProd('production', 'development')
})
]),
optimization: {
splitChunks: {
chunks: 'all'
}
}
};
};