forked from sayanee/angularjs-pdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
78 lines (72 loc) · 1.73 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
78
const webpack = require('webpack');
const pkg = require('./package.json');
const banner = `Angular-PDF: ${pkg.description}
@version ${pkg.version}
@link ${pkg.homepage}
@license MIT License, http://www.opensource.org/licenses/MIT`
var ENV = process.env.npm_lifecycle_event;
var isTest = ENV === 'test' || ENV === 'test-watch';
var isProdMin = ENV === 'build-min';
var isProd = ENV === 'build' || isProdMin;
var isExecuting = ENV === 'start';
var config = {
entry: "./src/angular-pdf.module.js",
devtool: (isProd) ? 'source-map' : 'inline-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
new webpack.BannerPlugin(banner),
new webpack.NamedModulesPlugin(),
],
devServer: {
contentBase: './example',
inline: true,
},
module: {
rules: [{
test: /src.*\.js$/,
loader: 'ng-annotate-loader'
}, {
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: [
"latest",
],
plugins: isTest ? [
"istanbul"
] : undefined
}
}
],
},
externals: {
"angular": "angular",
"pdfjs-dist": "pdfjs-dist"
}
};
if (isProd) {
config.plugins.push(
new webpack.NoEmitOnErrorsPlugin()
)
if (isProdMin) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: isProd
})
)
}
}
config.output = isTest ? {} : {
path: __dirname + '/dist',
publicPath: isProd ? '/' : 'http://localhost:8080/',
filename: "angular-pdf" + (isProdMin || isExecuting ? ".min" : "") + ".js",
library: "pdf",
libraryTarget: "umd",
umdNamedDefine: true
};
module.exports = config;