-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.babel.js
40 lines (37 loc) · 1.04 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
import path from 'path';
import {optimize} from 'webpack';
import packages, {makeScoped} from './packageList';
import {isMain} from './scripts/helpers';
import {
libName,
moduleProp,
minify,
banner,
} from './webpack.parts';
const {ModuleConcatenationPlugin} = optimize;
export default ({modern, cover}, {mode, cache}) => ({
mode,
entry: packages.reduce((pkgs, [{name}, file]) => (
{...pkgs, [name]: path.resolve(file)}
), {}),
devtool: 'source-map',
output: {
path: path.resolve('dist'),
filename: ({chunk: {name}}) => `${isMain(name) ? libName : makeScoped(name)}/${
(modern ? '' : 'legacy/') +
(mode === 'production' ? 'min' : 'index')
}.js`,
library: '[name]',
libraryTarget: 'umd',
libraryExport: 'default',
umdNamedDefine: true,
globalObject: 'typeof self !== \'undefined\' ? self : this',
pathinfo: false,
},
module: moduleProp(cache, modern, cover),
optimization: mode === 'production' ? minify() : {},
plugins: [
banner,
new ModuleConcatenationPlugin(),
],
});