-
Notifications
You must be signed in to change notification settings - Fork 20
/
webpack.config.babel.js
130 lines (122 loc) · 2.4 KB
/
webpack.config.babel.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { join } from 'path';
import merge from 'webpack-merge';
// eslint-disable-next-line import/no-extraneous-dependencies
import TerserPlugin from 'terser-webpack-plugin';
import ESLintPlugin from 'eslint-webpack-plugin';
const include = join(__dirname, 'src');
const browserConfig = {
entry: {
Addon: {
import: './src/addon',
filename: 'addon.js',
library: {
name: '[name]',
type: 'var',
},
},
AddonContainer: {
import: './src/addon-container',
filename: 'addon-container.js',
library: {
name: '[name]',
type: 'var',
},
},
},
output: {
path: join(__dirname, 'dist'),
},
optimization: {
minimize: false,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
},
mode: 'production',
module: {
rules: [
{ test: /\.js$/, loader: 'babel-loader', include },
],
},
};
const browserMinifiedConfig = merge(browserConfig, {
devtool: 'source-map',
entry: {
Addon: {
filename: 'addon.min.js',
},
AddonContainer: {
filename: 'addon-container.min.js',
},
},
optimization: {
minimize: true,
},
});
const browserES5Config = merge(browserConfig, {
entry: {
Addon: {
filename: 'addon.es5.js',
},
AddonContainer: {
filename: 'addon-container.es5.js',
},
},
target: ['web', 'es5'],
});
const browserES5MinifiedConfig = merge(browserES5Config, {
devtool: 'source-map',
entry: {
Addon: {
filename: 'addon.es5.min.js',
},
AddonContainer: {
filename: 'addon-container.es5.min.js',
},
},
optimization: {
minimize: true,
},
});
const commonJsConfig = merge(browserConfig, {
entry: {
Addon: {
library: {
type: 'commonjs',
},
},
AddonContainer: {
library: {
type: 'commonjs',
},
},
},
output: {
path: join(__dirname, 'lib'),
},
});
const commonJsES5Config = merge(commonJsConfig, {
entry: {
Addon: {
filename: 'addon.es5.js',
},
AddonContainer: {
filename: 'addon-container.es5.js',
},
},
plugins: [
// Have eslint here so it only run once instead of once for each build config
new ESLintPlugin(),
],
target: 'es5',
});
module.exports = [
browserConfig,
browserMinifiedConfig,
browserES5Config,
browserES5MinifiedConfig,
commonJsConfig,
commonJsES5Config,
];