import Vue from 'vue'
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
或 new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn/)
plugins[ new webpack.optimize.CommonsChunkPlugin({ name: ['vendor', 'manifest'], // 若是有manifest 每次打包壓縮後的文件不會改變hash minChunks: function (module, count) { // any required modules inside node_modules are extracted to vendor return ( module.resource && /\.js$/.test(module.resource) && module.resource.indexOf( path.join(__dirname, '../node_modules') ) === 0 ) } }),]
下圖優化大小:
後臺項目:總大小 20M 減小到4.2M 後臺4.2M, 在開啓gzip壓縮下,勉強湊合。javascript
優化後:
vue
移動端:2.0M減小到830K,開啓gzip 大概在400-500k左右。java