This repository has been archived by the owner on Jun 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathwebpack.config.js
77 lines (71 loc) · 1.91 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*eslint-env node, commonjs */
/*eslint comma-dangle:0 */
const webpack = require('webpack');
const NgAnnotatePlugin = require('ng-annotate-webpack-plugin');
const pkg = require('./package.json');
const banner = '' +
'/*! ' + (pkg.title || pkg.name) + ' - v' + (pkg.version) + ' - ' + (new Date().toISOString().substring(0, 10)) + '\n' +
' * ' + (pkg.homepage) + '\n' +
' * Copyright (c) ' + (new Date().toISOString().substring(0, 4)) + ' ' + (pkg.author.name) + '\n' +
' * @license ' + (pkg.license) + ' */' +
'';
const factory = function (options) {
var minified = options.minified || false;
var result = {
entry : {
'angular-vertxbus' : './src/index.js',
},
output : {
filename : minified ? 'dist/[name].min.js' : 'dist/[name].js',
libraryTarget : 'umd',
},
externals : [
{
'vertx-eventbus' : {
root : 'EventBus',
commonjs2 : 'vertx-eventbus',
commonjs : 'vertx-eventbus',
amd : 'vertx-eventbus',
}
}
],
module : {
loaders : [
{
enforce : 'pre',
test : /\.js$/,
exclude : /(node_modules|bower_components)/,
loader : 'eslint-loader',
},
{
test : /\.js$/,
exclude : /(node_modules|bower_components)/,
loader : 'babel-loader',
options : {
presets : ['env'],
plugins : ['transform-runtime']
},
},
]
},
plugins : [],
devtool : 'source-map',
};
result.plugins.push(new webpack.BannerPlugin({
banner : banner,
raw : true,
entryOnly : true,
}));
result.plugins.push(new NgAnnotatePlugin({
add : true,
}));
if (minified) {
result.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap : true,
}));
}
return result;
};
module.exports = factory({
minified : process.env.BUILD_MINIFIED ? true : false
});