1 |
|
2 |
|
3 |
|
4 | const webpack = require('webpack');
|
5 | const merge = require('webpack-merge');
|
6 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
7 | const FileManagerPlugin = require('filemanager-webpack-plugin');
|
8 | const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
9 | const cssProcessor = require('cssnano');
|
10 | const { BUNDLE_NAME, IS_PROD, IS_POS } = require('./helpers/consts.js');
|
11 | const MambaManifestPlugin = require('./plugins/MambaManifestPlugin.js');
|
12 | const { getPkg } = require('quickenv');
|
13 |
|
14 | const PKG = getPkg();
|
15 |
|
16 | module.exports = merge(require('./config.app.js'), {
|
17 | devtool: false,
|
18 | plugins: [
|
19 | IS_POS && new MambaManifestPlugin(),
|
20 | new FileManagerPlugin({
|
21 | onStart: {
|
22 | delete: [
|
23 | `./dist/${BUNDLE_NAME}`,
|
24 | `./dist/${BUNDLE_NAME}.tar.gz`,
|
25 | `./dist/${BUNDLE_NAME}.ppk`,
|
26 | ],
|
27 | },
|
28 | onEnd: {
|
29 | copy: [
|
30 | {
|
31 | source: './src/assets',
|
32 | destination: `./dist/${BUNDLE_NAME}/assets`,
|
33 | },
|
34 | ],
|
35 | archive: [
|
36 | {
|
37 | source: `./dist/${BUNDLE_NAME}/`,
|
38 | destination: `./dist/${BUNDLE_NAME}.tar.gz`,
|
39 | format: 'tar',
|
40 | options: {
|
41 | gzip: true,
|
42 | gzipOptions: { level: 1 },
|
43 | globOptions: { nomount: true },
|
44 | },
|
45 | },
|
46 | {
|
47 | source: `./dist/${BUNDLE_NAME}/`,
|
48 | destination: `./dist/${PKG.name}_v${PKG.version}.ppk`,
|
49 | format: 'zip',
|
50 | options: {
|
51 | gzip: true,
|
52 | gzipOptions: { level: 1 },
|
53 | globOptions: { nomount: true },
|
54 | },
|
55 | },
|
56 | ],
|
57 | },
|
58 | }),
|
59 |
|
60 | IS_PROD && new webpack.HashedModuleIdsPlugin(),
|
61 | ].filter(Boolean),
|
62 | optimization: {
|
63 | minimize: IS_PROD,
|
64 | minimizer: [
|
65 |
|
66 | new OptimizeCSSAssetsPlugin({
|
67 |
|
68 | cssProcessor,
|
69 | cssProcessorOptions: {
|
70 | core: IS_PROD,
|
71 | discardComments: IS_PROD,
|
72 | autoprefixer: false,
|
73 | },
|
74 | }),
|
75 |
|
76 | new UglifyJsPlugin({
|
77 | cache: true,
|
78 | parallel: true,
|
79 | sourceMap: true,
|
80 | uglifyOptions: {
|
81 | compress: {
|
82 | reduce_funcs: false,
|
83 | keep_fnames: false,
|
84 |
|
85 | pure_funcs: [
|
86 | 'classCallCheck',
|
87 | '_classCallCheck',
|
88 | '_possibleConstructorReturn',
|
89 | 'Object.freeze',
|
90 | 'invariant',
|
91 | 'warning',
|
92 | ],
|
93 | },
|
94 | mangle: {
|
95 | keep_fnames: false,
|
96 |
|
97 | reserved: ['process'],
|
98 | },
|
99 | output: {
|
100 | comments: false,
|
101 | },
|
102 | },
|
103 | }),
|
104 | ],
|
105 | },
|
106 | });
|