webpack 提升90%的构建速度 HardSourceWebpackPlugin


 

 

 

 

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM