-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.production.js
49 lines (38 loc) · 1.75 KB
/
webpack.config.production.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
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _path = _interopRequireDefault(require("path"));
var _fs = _interopRequireDefault(require("fs"));
var _webpack = _interopRequireDefault(require("webpack"));
var _terserWebpackPlugin = _interopRequireDefault(require("terser-webpack-plugin"));
var _webpackVendorReplace = _interopRequireDefault(require("./webpack.vendorReplace.plugin"));
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
var _cssMinimizerWebpackPlugin = _interopRequireDefault(require("css-minimizer-webpack-plugin"));
var _webpackConfig = _interopRequireDefault(require("./webpack.config.js"));
var manifest = JSON.parse(_fs.default.readFileSync(_path.default.join(process.cwd(), 'manifest.json')));
var type = Object.keys(manifest)[0];
var tag = Object.keys(manifest[type])[0];
delete _webpackConfig.default.devtool;
module.exports = Object.assign({}, _webpackConfig.default, {
mode: 'production',
optimization: Object.assign({}, _webpackConfig.default.optimization, {
minimize: true,
mangleExports: false,
minimizer: [new _terserWebpackPlugin.default({
terserOptions: {
safari10: true
}
}), new _cssMinimizerWebpackPlugin.default()]
}),
plugins: [new _miniCssExtractPlugin.default({
filename: '[name].bundle.css'
}), new _webpack.default.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
DEBUG: JSON.stringify('false'),
platform: JSON.stringify('unix'),
NODE_DEBUG: JSON.stringify('false')
},
'process.platform': JSON.stringify('unix'),
'fs.promises.readFile': JSON.stringify(false)
}), new _webpackVendorReplace.default(tag + '/index.js', type)]
});