forked from DDMAL/diva.js
/
get-webpack-config.js
51 lines (45 loc) · 1.2 KB
/
get-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
var webpack = require('webpack');
module.exports = function (mode, options)
{
var isCompressed = options && options.compress;
var outputFilename;
if (options && options.outputFilename)
outputFilename = options.outputFilename;
else if (isCompressed)
outputFilename = 'diva.min.js';
else
outputFilename = 'diva.js';
var config = {
entry: [
'./source/js/register-builtin-plugins.js',
// The export
'./source/js/diva.js'
],
output: {
path: __dirname + '/build/js',
filename: outputFilename,
library: 'diva',
libraryTarget: 'umd'
},
externals: {
jquery: {
root: 'jQuery',
amd: 'jquery',
commonjs: 'jquery',
commonjs2: 'jquery'
}
},
devtool: mode === 'production' ? 'cheap-sourcemap' : 'inline-source-map'
};
if (isCompressed)
{
config.plugins = [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
];
}
return config;
};