-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-prod-min.js
63 lines (57 loc) · 1.73 KB
/
webpack-prod-min.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
const path = require('path');
const {
CleanWebpackPlugin
} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require("terser-webpack-plugin");
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
/* This generates the minified CSS production code.
* It compresses both CSS and JavaScript
* terser compresses javascript, 'optimize-css-assets-webpack-plugin' compresses css
* This works with the CSS-non-minify.js script, but this must run first
*/
module.exports = {
entry: {
main: './src/stooge.js',
responsive: './src/stooge-responsive.js',
colors: './src/stooge-colors.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
// since there is no JS, just css, ignore the output
filename: '../rubbish/[name]-ignore.js',
},
plugins: [
new MiniCssExtractPlugin({
filename: (pathData) => {
return pathData.chunk.name === 'main' ? 'stooge.min.css' : 'stooge-[name].min.css'
},
}),
new CleanWebpackPlugin({})
],
module: {
rules: [{
test: /\.css$/i,
use: [{
loader: MiniCssExtractPlugin.loader
},
"css-loader",
]
}],
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
terserOptions: {
format: {
comments: /^\@/
}
},
extractComments: false,
}),
new OptimizeCssAssetsPlugin({})
],
},
mode: 'production',
// devtool: "source-map",
}