-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
54 lines (49 loc) · 1.44 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
const objectRestSpread = require('@babel/plugin-proposal-object-rest-spread')
const path = require('path')
const webpack = require('webpack')
const packageConfig = require('./package.json')
const banner = `${packageConfig.name} ${packageConfig.version}
${packageConfig.repository.url}
Includes htmlparser2
https://github.com/fb55/htmlparser2/
https://github.com/fb55/htmlparser2/raw/master/LICENSE
@license ${packageConfig.license}
${packageConfig.repository.url}/raw/master/LICENSE`
const basename = path.basename(packageConfig.main, '.js')
const browsers = ['> 1%', 'last 2 versions', 'Firefox ESR', 'IE >= 9']
const configuration = {
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'umd',
umdNamedDefine: true,
},
plugins: [new webpack.BannerPlugin(banner)],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
babelrc: false,
presets: [
[
'@babel/preset-env',
{ modules: false, targets: { browsers }, useBuiltIns: 'usage' },
],
],
plugins: [[objectRestSpread, { useBuiltIns: true }]],
},
},
],
},
}
exports.default = [
{
...configuration,
entry: { [basename]: './entry.js' },
optimization: { minimize: false },
},
{ ...configuration, entry: { [`${basename}.min`]: './entry.js' } },
]