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