-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
58 lines (57 loc) · 1.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
const path = require('path');
module.exports = [{
name: "dev",
entry: {
embed: path.resolve(__dirname, 'src', 'embed.js'),
count: path.resolve(__dirname, 'src', 'count.js'),
},
/* https://webpack.js.org/configuration/mode/
* Available modes: development, production, none
*/
mode: 'development',
/* https://webpack.js.org/configuration/devtool/ */
devtool: 'source-map',
/* Instruct webpack to emit ES5-compatible syntax for not-so-recent (pre-2017) browsers
* Note: Both 'web' and 'es5' are needed!
* https://webpack.js.org/configuration/target/ */
target: ['web', 'es5'],
/* https://webpack.js.org/configuration/resolve/#resolvemodules */
resolve: {
modules: [
path.resolve(__dirname, 'src'),
'node_modules',
],
},
/* https://webpack.js.org/guides/asset-modules/ */
module: {
rules: [{
/* Read raw file contents when `require`-ing .svg files */
test: /\.svg/,
type: 'asset/source'
}, ],
},
/* https://webpack.js.org/concepts/output/ */
output: {
filename: '[name].dev.js',
path: path.resolve(__dirname, 'dist'),
},
}, {
name: "prod",
// https://webpack.js.org/configuration/configuration-types/#dependencies
dependencies: ["dev", ],
mode: 'production',
optimization: {
/* Tree shaking
* https://webpack.js.org/guides/tree-shaking/ */
usedExports: true,
// sideEffects=true, evaluates package.json sideEffects of inherited
// modules for tree-shaking of unused imports
// on by default for prod builds
//sideEffects: true,
},
devtool: false, // no eval or source maps in prod
output: {
filename: '[name].min.js',
path: path.resolve(__dirname, 'dist'),
}
}, ];