-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.plugins.js
37 lines (36 loc) · 1 KB
/
webpack.plugins.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
const path = require("path");
const webpack = require("webpack");
const WebpackBar = require("webpackbar");
const AssetsPlugin = require("assets-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = (DEV = false, PATHS = {}) => {
return [
new WebpackBar(),
new webpack.DefinePlugin({
"process.env": {
DEV: DEV ? JSON.stringify(true) : JSON.stringify(false)
}
}),
// in dev mode only
...(DEV
? [
new webpack.LoaderOptionsPlugin({
debug: true
}),
new webpack.HotModuleReplacementPlugin()
]
: // prod only
[
new MiniCssExtractPlugin({
filename: "css/[name].css?hash=[chunkhash]",
chunkFilename: "css/[name].css"
}),
new AssetsPlugin({
path: path.resolve(PATHS.dist),
filename: `assets.json`,
prettyPrint: true,
includeAllFileTypes: false
})
])
];
};;