@@ -6,7 +6,6 @@ const config = require('../config')
6
6
const merge = require ( 'webpack-merge' )
7
7
const baseWebpackConfig = require ( './webpack.base.conf' )
8
8
const CopyWebpackPlugin = require ( 'copy-webpack-plugin' )
9
- const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
10
9
const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' )
11
10
const OptimizeCSSPlugin = require ( 'optimize-css-assets-webpack-plugin' )
12
11
const UglifyJsPlugin = require ( 'uglifyjs-webpack-plugin' )
@@ -24,8 +23,8 @@ const webpackConfig = merge(baseWebpackConfig, {
24
23
devtool : config . build . productionSourceMap ? config . build . devtool : false ,
25
24
output : {
26
25
path : config . build . assetsRoot ,
27
- filename : utils . assetsPath ( 'js/[name].[chunkhash].js' ) ,
28
- chunkFilename : utils . assetsPath ( 'js/[id].[chunkhash].js' )
26
+ filename : utils . assetsPath ( 'js/[name].[chunkhash:8 ].js' ) ,
27
+ chunkFilename : utils . assetsPath ( 'js/[id].[chunkhash:8 ].js' )
29
28
} ,
30
29
plugins : [
31
30
// http://vuejs.github.io/vue-loader/en/workflow/production.html
@@ -43,10 +42,10 @@ const webpackConfig = merge(baseWebpackConfig, {
43
42
} ) ,
44
43
// extract css into its own file
45
44
new ExtractTextPlugin ( {
46
- filename : utils . assetsPath ( 'css/[name].[contenthash].css' ) ,
45
+ filename : utils . assetsPath ( 'css/[name].[contenthash:8 ].css' ) ,
47
46
// Setting the following option to `false` will not extract CSS from codesplit chunks.
48
47
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
49
- // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
48
+ // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
50
49
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
51
50
allChunks : true ,
52
51
} ) ,
@@ -57,32 +56,24 @@ const webpackConfig = merge(baseWebpackConfig, {
57
56
? { safe : true , map : { inline : false } }
58
57
: { safe : true }
59
58
} ) ,
60
- // generate dist index.html with correct asset hash for caching.
61
- // you can customize output by editing /index.html
62
- // see https://github.com/ampedandwired/html-webpack-plugin
63
- new HtmlWebpackPlugin ( {
64
- filename : config . build . index ,
65
- template : 'index.html' ,
66
- inject : true ,
67
- minify : {
68
- removeComments : true ,
69
- collapseWhitespace : true ,
70
- removeAttributeQuotes : true
71
- // more options:
72
- // https://github.com/kangax/html-minifier#options-quick-reference
73
- } ,
74
- // necessary to consistently work with multiple chunks via CommonsChunkPlugin
75
- chunksSortMode : 'dependency'
76
- } ) ,
59
+
77
60
// keep module.id stable when vendor modules does not change
78
61
new webpack . HashedModuleIdsPlugin ( ) ,
79
62
// enable scope hoisting
80
63
new webpack . optimize . ModuleConcatenationPlugin ( ) ,
81
- // split vendor js into its own file
64
+
65
+ // copy custom static assets
66
+ new CopyWebpackPlugin ( [
67
+ {
68
+ from : path . resolve ( __dirname , '../static' ) ,
69
+ to : config . build . assetsSubDirectory ,
70
+ ignore : [ '.*' ]
71
+ }
72
+ ] ) ,
73
+
82
74
new webpack . optimize . CommonsChunkPlugin ( {
83
75
name : 'vendor' ,
84
76
minChunks ( module ) {
85
- // any required modules inside node_modules are extracted to vendor
86
77
return (
87
78
module . resource &&
88
79
/ \. j s $ / . test ( module . resource ) &&
@@ -92,31 +83,19 @@ const webpackConfig = merge(baseWebpackConfig, {
92
83
)
93
84
}
94
85
} ) ,
95
- // extract webpack runtime and module manifest to its own file in order to
96
- // prevent vendor hash from being updated whenever app bundle is updated
86
+
97
87
new webpack . optimize . CommonsChunkPlugin ( {
98
88
name : 'manifest' ,
99
89
minChunks : Infinity
100
90
} ) ,
101
- // This instance extracts shared chunks from code splitted chunks and bundles them
102
- // in a separate chunk, similar to the vendor chunk
103
- // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
91
+
104
92
new webpack . optimize . CommonsChunkPlugin ( {
105
93
name : 'app' ,
106
94
async : 'vendor-async' ,
107
95
children : true ,
108
96
minChunks : 3
109
- } ) ,
110
-
111
- // copy custom static assets
112
- new CopyWebpackPlugin ( [
113
- {
114
- from : path . resolve ( __dirname , '../static' ) ,
115
- to : config . build . assetsSubDirectory ,
116
- ignore : [ '.*' ]
117
- }
118
- ] )
119
- ]
97
+ } )
98
+ ] . concat ( utils . htmlPlugins ( ) )
120
99
} )
121
100
122
101
if ( config . build . productionGzip ) {
0 commit comments