-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
52 lines (48 loc) · 1.4 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
const {resolve} = require('path')
const {DefinePlugin, optimize} = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = function createWebpackConfig(env) {
const DEFAULT_PLUGINS = [
new DefinePlugin({
PROD: JSON.stringify(env.prod)
}),
new HtmlWebpackPlugin({
template: './app/index.html'
})
];
const PRODUCTION_PLUGINS = [
new optimize.UglifyJsPlugin({
compress: { warnings: false }
}),
new optimize.DedupePlugin()
];
const PLUGINS = env.prod ? [ ...DEFAULT_PLUGINS, ...PRODUCTION_PLUGINS ]: DEFAULT_PLUGINS;
return {
entry: './app/index',
output: {
filename: 'bundle.js',
path: resolve(__dirname, 'dist'),
pathinfo: !env.prod,
},
devtool: env.prod ? 'source-map' : 'eval',
bail: env.prod,
resolve: {
extensions: ['.ts', '.js', '.json'],
},
plugins: PLUGINS,
devServer: { },
module: {
loaders: [
{test: /\.ts$/, loader: 'ts', exclude: /node_modules/},
{ test: /\.js$/, loader: 'babel', exclude: /node_modules/ },
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.json$/, loader: 'json-loader' },
{
test: /(\.png?$|\.jpg?$|\.jpeg?$|\.svg?$|\.eot?$|\.ttf?$|\.woff?$|\.woff2?$|\.wav?$|\.mp3?$|\.ico?$)/,
loader: 'file'
}
],
},
};
};