-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
98 lines (92 loc) · 2.31 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const webpack = require('webpack');
const path = require('path');
const libraryName = 'rechtspraak';
/**
* Webpack plugins, depending on commandline flags.
* @return Array
*/
function getPlugins ({/*debug, */minify}) {
//noinspection JSUnresolvedFunction
const plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(minify ? 'production' : 'development')
}
),
new webpack.LoaderOptionsPlugin({
debug: false,
minimize: minify,
options: {
context: __dirname,
/*postcss: [
cssnext({
browsers: ['last 2 version', 'ie >= 11']
})
]*/
}
})/*,
new ExtractTextPlugin(minify ? '[name].min.css' : '[name].css')*/
];
if (minify) {
//noinspection JSUnresolvedVariable,JSUnresolvedFunction
plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
screw_ie8: true,
warnings: false
},
output: {
comments: false
}
})
)
}
/* uncomment if using mutiple entry points
if (minify) {
plugins.push(
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
})
)
}
*/
/*
plugins.push(
new HtmlWebpackPlugin({
filename: 'index.html',
template: resolve(__dirname, 'src/index.html'),
minify: minify ? {
removeComments: true,
collapseWhitespace: true
} : false
})
);*/
return plugins
}
/**
* Generates a Webpack config.
* @param {Boolean} debug
* @param {Boolean} minify
* @return {Object}
*/
module.exports = ({debug = false, minify = false} = {}) => ({
entry: './src/index.ts',
devtool: 'source-map',
output: {
path: './dist',
filename: libraryName+".js",
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
loaders: [
{
test: /\.tsx?$/,
loader: "awesome-typescript-loader",
exclude: /(node_modules|bower_components)/
}
]
},
plugins: getPlugins({debug, minify})
});