forked from nervgh/angular-file-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebpackConfig.js
72 lines (67 loc) · 1.67 KB
/
WebpackConfig.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
'use strict';
// http://webpack.github.io/docs/
let webpack = require('webpack');
class WebpackConfig {
/**
* @param {Object} descriptor
* @param {String} descriptor.name
* @param {String} descriptor.version
* @param {String} descriptor.homepage
* @param {Object} path
* @param {String} path.src
* @param {String} path.dist
*/
constructor(descriptor, path) {
this.name = descriptor.name;
this.version = descriptor.version;
this.homepage = descriptor.homepage;
this.path = path;
}
/**
* @returns {Object}
*/
get() {
let entry = {};
entry[this.name] = this.path.src;
entry[this.name + '.min'] = this.path.src;
return {
entry,
module: {
loaders: [
// https://github.com/babel/babel-loader
{
test: /\.js$/,
loader: 'babel'
},
// https://github.com/webpack/json-loader
{test: /\.json$/, loader: 'json'},
// https://github.com/webpack/html-loader
{test: /\.html$/, loader: 'raw'}
]
},
devtool: 'source-map',
output: {
libraryTarget: 'umd',
library: this.name,
filename: '[name].js'
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
// Minify only [name].min.js file
// http://stackoverflow.com/a/34018909
include: /\.min\.js$/
}),
new webpack.BannerPlugin(
`/*\n` +
` ${this.name} v${this.version}\n` +
` ${this.homepage}\n` +
`*/\n`
, {
entryOnly: true,
raw: true
})
]
};
}
}
module.exports = WebpackConfig;