webpack 提升90%的构建速度 HardSourceWebpackPlugin

时间:2018-04-07 12:41:55   收藏:0   阅读:4365

 

 

 

 

HardSourceWebpackPlugin 插件 不能提升第一次构建的速度,但对于第二次构建能提升99%的构建速度

第一次构建:

技术分享图片

 

 第二次:

技术分享图片

 

提升了。。,算不出来,反正就是很多啦~~~

 

npm install --save hard-source-webpack-plugin

 

// webpack.config.js
var HardSourceWebpackPlugin = require(hard-source-webpack-plugin);

new HardSourceWebpackPlugin({
  // Either an absolute path or relative to webpack‘s options.context.
  cacheDirectory: node_modules/.cache/hard-source/[confighash],
  // Either an absolute path or relative to webpack‘s options.context.
  // Sets webpack‘s recordsPath if not already set.
  recordsPath: node_modules/.cache/hard-source/[confighash]/records.json,
  // Either a string of object hash function given a webpack config.
  configHash: function(webpackConfig) {
    // node-object-hash on npm can be used to build this.
    return require(node-object-hash)({sort: false}).hash(webpackConfig);
  },
  // Either false, a string, an object, or a project hashing function.
  environmentHash: {
    root: process.cwd(),
    directories: [],
    files: [package-lock.json, yarn.lock],
  },
}),

 

https://github.com/mzgoddard/hard-source-webpack-plugin

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!