-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
72 lines (65 loc) · 2.06 KB
/
webpack.prod.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
/**
* 本地预览
*/
var path = require('path');
var fs = require('fs');
var webpack = require('webpack');
// var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var merge = require('webpack-merge');
var webpackBaseConfig = require('./webpack.base.config.js');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
process.env.NODE_ENV = '"production"'
module.exports = merge(webpackBaseConfig, {
// 入口
entry: {
main: './src/main',
vendors: ['vue', 'vue-router']
},
// 输出
output: {
path:path.join(__dirname, './dist-prod'),
publicPath: '',
filename: '[name].[hash].js',
chunkFilename: '[name].chunk.[hash].js'
},
resolve: {
alias: {
vlc: './src/index',
vue: 'vue/dist/vue.js'
}
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': process.env.NODE_ENV,
}),
// new ExtractTextPlugin({ filename: '[name].css', disable: true, allChunks: true }),
new webpack.optimize.CommonsChunkPlugin({ name: 'vendors', filename: 'vendor.bundle.[hash].js' }),
new webpack.LoaderOptionsPlugin({
// test: /\.xxx$/, // may apply this only for some modules
options: {
babel:{
presets: ['es2015','stage-0'],
plugins: ['transform-runtime']
}
}
}),
new HtmlWebpackPlugin({
inject: true,
filename: '../dist-prod/index.html',
template: './src/template/index.ejs'
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_debugger: true,
drop_console: true
},
output: { // 删除打包后的注释
comments: false
}
}),
new FriendlyErrorsPlugin()
]
});