-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
111 lines (99 loc) · 2.69 KB
/
webpack.config.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
require('dotenv').config();
const path = require('path');
const webpack = require('webpack')
const ZipPlugin = require('zip-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const rm = require('rimraf');
rm.sync('./dist')
const production = process.env.SCATTER_ENV === 'production';
const staticPlugins = [
new Dotenv(),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }),
new webpack.HashedModuleIdsPlugin(),
];
const prodPlugins = staticPlugins.concat([
new ZipPlugin({ path: '../', filename: 'scatter.zip' }),
])
const productionPlugins = !production ? staticPlugins : prodPlugins;
const replaceSuffixes = (file) => file.replace('scss', 'css');
const filesToPack = [
'background.js',
'wallet_content.js',
'wallet_inject.js',
'app_inject.js',
'app_content.js',
];
const entry = filesToPack.reduce((o, file) => Object.assign(o, {[replaceSuffixes(file)]: `./src/${file}`}), {});
module.exports = {
entry,
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name]',
chunkFilename: '[name].bundle.js',
},
resolve: {
extensions: ['.js', '.vue', '.json'],
modules: [ path.join(__dirname, "node_modules") ]
},
optimization: {
minimize: false,
},
// optimization: {
// minimizer: [
// new TerserPlugin({
// cache: true,
// parallel: true,
// sourceMap: false, // Must be set to true if using source-maps in production
// terserOptions: {
// // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
// ecma: undefined,
// warnings: false,
// parse: {},
// compress: {},
// mangle: true, // Note `mangle.properties` is `false` by default.
// module: false,
// output: null,
// toplevel: false,
// nameCache: null,
// ie8: false,
// keep_classnames: undefined,
// keep_fnames: false,
// safari10: false,
// }
// })
// ],
// namedModules: false,
// namedChunks: false,
// nodeEnv: 'production',
// flagIncludedChunks: true,
// occurrenceOrder: true,
// sideEffects: true,
// usedExports: true,
// concatenateModules: true,
// noEmitOnErrors: true,
// checkWasmTypes: true,
// minimize: true,
// splitChunks: {
// chunks: 'all',
// cacheGroups: {
// commons: {
// test: /[\\/]node_modules[\\/]/,
// name: 'vendor',
// chunks: 'all',
// // maxSize: 500000,
// }
// }
// }
// },
module: {
rules: []
},
plugins: [
new CopyWebpackPlugin([`./static/`]),
new CopyWebpackPlugin([`./html/`]),
].concat(productionPlugins),
stats: { colors: true },
devtool: 'inline-source-map', //inline-
}