-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
74 lines (72 loc) · 1.96 KB
/
webpack.config.js
File metadata and controls
74 lines (72 loc) · 1.96 KB
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
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
module.exports = (env, argv) => {
const isProduction = argv.mode === 'production';
return {
entry: {
app: './static/js/app.js',
auth: './static/js/auth.js',
state: './static/js/state.js',
styles: [
'./static/css/desktop.css',
'./static/css/mobile.css',
'./static/css/logo-styles.css'
]
},
output: {
filename: isProduction ? 'js/[name].[contenthash:8].js' : 'js/[name].js',
path: path.resolve(__dirname, 'static/dist'),
clean: true,
publicPath: '/static/dist/'
},
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: isProduction ? 'css/[name].[contenthash:8].css' : 'css/[name].css'
}),
new WebpackManifestPlugin({
fileName: 'manifest.json',
publicPath: '/static/dist/',
generate: (seed, files) => {
return files.reduce((manifest, file) => {
const name = file.name.replace(/\.[a-f0-9]{8}\./, '.');
manifest[name] = file.path;
return manifest;
}, seed);
}
})
],
optimization: {
minimize: isProduction,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: false,
pure_funcs: []
},
format: {
comments: false
}
},
extractComments: false
}),
new CssMinimizerPlugin()
]
},
devtool: isProduction ? false : 'source-map'
};
};