Skip to content

Commit cde8f0a

Browse files
Revert: remove prod
1 parent 53acfee commit cde8f0a

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

build/webpack.prod.conf.js

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var utils = require('./utils')
4+
var webpack = require('webpack')
5+
var merge = require('webpack-merge')
6+
var baseWebpackConfig = require('./webpack.base.conf')
7+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
8+
var HtmlWebpackPlugin = require('html-webpack-plugin')
9+
var env = config.build.env
10+
11+
var webpackConfig = merge(baseWebpackConfig, {
12+
module: {
13+
loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true })
14+
},
15+
devtool: config.build.productionSourceMap ? '#source-map' : false,
16+
output: {
17+
path: config.build.assetsRoot,
18+
filename: utils.assetsPath('js/[name].[chunkhash].js'),
19+
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
20+
},
21+
vue: {
22+
loaders: utils.cssLoaders({
23+
sourceMap: config.build.productionSourceMap,
24+
extract: true
25+
})
26+
},
27+
plugins: [
28+
// http://vuejs.github.io/vue-loader/en/workflow/production.html
29+
new webpack.DefinePlugin({
30+
'process.env': env
31+
}),
32+
new webpack.optimize.UglifyJsPlugin({
33+
compress: {
34+
warnings: false
35+
}
36+
}),
37+
new webpack.optimize.OccurrenceOrderPlugin(),
38+
// extract css into its own file
39+
new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')),
40+
// generate dist index.html with correct asset hash for caching.
41+
// you can customize output by editing /index.html
42+
// see https://github.com/ampedandwired/html-webpack-plugin
43+
new HtmlWebpackPlugin({
44+
filename: config.build.index,
45+
template: 'index.html',
46+
inject: true,
47+
minify: {
48+
removeComments: true,
49+
collapseWhitespace: true,
50+
removeAttributeQuotes: true
51+
// more options:
52+
// https://github.com/kangax/html-minifier#options-quick-reference
53+
},
54+
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
55+
chunksSortMode: 'dependency'
56+
}),
57+
// split vendor js into its own file
58+
new webpack.optimize.CommonsChunkPlugin({
59+
name: 'vendor',
60+
minChunks: function (module, count) {
61+
// any required modules inside node_modules are extracted to vendor
62+
return (
63+
module.resource &&
64+
/\.js$/.test(module.resource) &&
65+
module.resource.indexOf(
66+
path.join(__dirname, '../node_modules')
67+
) === 0
68+
)
69+
}
70+
}),
71+
// extract webpack runtime and module manifest to its own file in order to
72+
// prevent vendor hash from being updated whenever app bundle is updated
73+
new webpack.optimize.CommonsChunkPlugin({
74+
name: 'manifest',
75+
chunks: ['vendor']
76+
})
77+
]
78+
})
79+
80+
if (config.build.productionGzip) {
81+
var CompressionWebpackPlugin = require('compression-webpack-plugin')
82+
83+
webpackConfig.plugins.push(
84+
new CompressionWebpackPlugin({
85+
asset: '[path].gz[query]',
86+
algorithm: 'gzip',
87+
test: new RegExp(
88+
'\\.(' +
89+
config.build.productionGzipExtensions.join('|') +
90+
')$'
91+
),
92+
threshold: 10240,
93+
minRatio: 0.8
94+
})
95+
)
96+
}
97+
98+
module.exports = webpackConfig

0 commit comments

Comments
 (0)