Skip to content

Commit 8d90e34

Browse files
committed
fix(Build): Fix #14
1 parent 66c5489 commit 8d90e34

File tree

1 file changed

+46
-31
lines changed

1 file changed

+46
-31
lines changed

packages/cli/template/webpack.config.js

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,54 @@ const webpack = require('webpack')
22
const path = require('path')
33
const HtmlWebpackPlugin = require('html-webpack-plugin')
44
const DashboardPlugin = require('webpack-dashboard/plugin')
5+
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
56
const nodeEnv = process.env.NODE_ENV || 'development'
67
const isProd = nodeEnv === 'production'
78

9+
const plugins = [
10+
new UglifyJsPlugin({
11+
parallel: true,
12+
uglifyOptions: {
13+
ie8: false,
14+
ecma: 6,
15+
warnings: true,
16+
mangle: isProd, // debug false
17+
output: {
18+
comments: false,
19+
beautify: !isProd, // debug true
20+
}
21+
},
22+
sourceMap: true
23+
}),
24+
new webpack.DefinePlugin({
25+
'process.env': {
26+
// eslint-disable-line quote-props
27+
NODE_ENV: JSON.stringify(nodeEnv)
28+
}
29+
}),
30+
new HtmlWebpackPlugin({
31+
title: 'Typescript Webpack Starter',
32+
template: '!!ejs-loader!src/index.html'
33+
}),
34+
new webpack.optimize.CommonsChunkPlugin({
35+
name: 'vendor',
36+
minChunks: Infinity,
37+
filename: 'vendor.bundle.js'
38+
}),
39+
new webpack.LoaderOptionsPlugin({
40+
options: {
41+
tslint: {
42+
emitErrors: true,
43+
failOnHint: true
44+
}
45+
}
46+
})
47+
];
48+
49+
if (!isProd) {
50+
plugins.push(new DashboardPlugin());
51+
}
52+
853
var config = {
954
devtool: isProd ? 'hidden-source-map' : 'source-map',
1055
context: path.resolve('./src'),
@@ -43,37 +88,7 @@ var config = {
4388
resolve: {
4489
extensions: ['.ts', '.js']
4590
},
46-
plugins: [
47-
new webpack.DefinePlugin({
48-
'process.env': {
49-
// eslint-disable-line quote-props
50-
NODE_ENV: JSON.stringify(nodeEnv)
51-
}
52-
}),
53-
new HtmlWebpackPlugin({
54-
title: 'Typescript Webpack Starter',
55-
template: '!!ejs-loader!src/index.html'
56-
}),
57-
new webpack.optimize.CommonsChunkPlugin({
58-
name: 'vendor',
59-
minChunks: Infinity,
60-
filename: 'vendor.bundle.js'
61-
}),
62-
new webpack.optimize.UglifyJsPlugin({
63-
compress: { warnings: false },
64-
output: { comments: false },
65-
sourceMap: true
66-
}),
67-
new DashboardPlugin(),
68-
new webpack.LoaderOptionsPlugin({
69-
options: {
70-
tslint: {
71-
emitErrors: true,
72-
failOnHint: true
73-
}
74-
}
75-
})
76-
],
91+
plugins: plugins,
7792
devServer: {
7893
contentBase: path.join(__dirname, 'dist/'),
7994
compress: true,

0 commit comments

Comments
 (0)