-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.prod.js
71 lines (67 loc) · 1.79 KB
/
webpack.prod.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
const merge = require("webpack-merge").merge;
const common = require("./webpack.common.js");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = merge(common, {
mode: "production",
devtool: "source-map",
optimization: {
providedExports: true,
usedExports: true,
minimize: true,
minimizer: [
new TerserPlugin({
test: /\.(js|jsx)$/,
extractComments: {
condition: /^\**!/i,
filename: (fileData) => {
// The "fileData" argument contains object with "filename", "basename", "query" and "hash"
return `${fileData.filename}.LICENSE.txt${fileData.query}`;
},
banner: (licenseFile) => {
return "";
},
},
parallel: true,
terserOptions: {
format: {
//comments: false,
preamble: process.env.TOP_BANNER,
},
},
}),
new CssMinimizerPlugin({
test: /\.(sa|sc|c)ss$/i,
}),
],
},
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/i,
//exclude: /node_modules/u,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "sass-loader",
options: {
implementation: require("sass"), // Prefer `dart-sass`
},
},
],
//use: ["style-loader", "css-loader"],
},
],
},
output: {
filename: common.output.filename.replace(/\.js$/, ".min.js"),
},
plugins: [
new MiniCssExtractPlugin({
filename: common.output.filename.replace(/\.js$/, ".min.css"),
}),
//, new BundleAnalyzerPlugin()
],
});