This repository has been archived by the owner on Apr 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpackfile.js
62 lines (51 loc) · 1.5 KB
/
webpackfile.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
const webpack = require('webpack');
const LIB_NAME = 'XHRShaper';
const configs = [];
const environment = process.env.NODE_ENV;
console.log('Building', LIB_NAME, 'with NODE_ENV:', environment, '\n');
function makeConfig(options) {
const libName = options.libName || LIB_NAME;
console.log('Making build config for:', libName, 'with options:\n', options, '\n');
const baseConfig = {
context: __dirname,
devtool: 'source-map',
entry: options.entry,
externals: options.externals,
output: {
path: __dirname + "/dist",
publicPath: "/dist/",
filename: libName + '.' + options.libraryTarget + ".js",
library: libName,
libraryTarget: options.libraryTarget,
sourceMapFilename: '[file].map'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
},
plugins: [
//new webpack.optimize.DedupePlugin(),
//new webpack.optimize.OccurrenceOrderPlugin()
]
};
return baseConfig;
}
configs.push(makeConfig({
libraryTarget: 'umd',
entry: './index',
}));
configs.push(makeConfig({
libraryTarget: 'this',
entry: './index'
}));
module.exports = configs;