Skip to content

Commit c3e70ad

Browse files
committed
webpack: add configuration for production env
1 parent 7f2b99f commit c3e70ad

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

template/webpack.config.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const webpack = require('webpack');
2-
const ExtractTextPlugin = require("extract-text-webpack-plugin");
2+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
33
const WebpackShellPlugin = require('webpack-shell-plugin');
44
const CopyWebpackPlugin = require('copy-webpack-plugin');
55

@@ -42,8 +42,8 @@ const config = {
4242
{
4343
test: /\.css$/,
4444
use: ExtractTextPlugin.extract({
45-
use: "css-loader",
46-
fallback: "vue-loader",
45+
use: 'css-loader',
46+
fallback: 'vue-loader',
4747
})
4848
},
4949
{
@@ -70,4 +70,25 @@ const config = {
7070
]
7171
};
7272

73+
if (process.env.NODE_ENV === 'production') {
74+
config.devtool = '#cheap-module-source-map';
75+
76+
config.plugins = (config.plugins || []).concat([
77+
new webpack.DefinePlugin({
78+
'process.env': {
79+
NODE_ENV: '"production"'
80+
}
81+
}),
82+
new webpack.optimize.UglifyJsPlugin({
83+
sourceMap: true,
84+
compress: {
85+
warnings: false
86+
}
87+
}),
88+
new webpack.LoaderOptionsPlugin({
89+
minimize: true
90+
})
91+
]);
92+
}
93+
7394
module.exports = config;

0 commit comments

Comments
 (0)