yarn add hard-source-webpack-plugin

经常会遇见这样一种情况,改为一部分代码,保存时会编译很久才能看见效果,这个插件可以缓存中间的编译过程,使速度提升90%

const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

    plugins: [
      new HardSourceWebpackPlugin({
        cacheDirectory: 'node_modules/.cache/hard-source/[confighash]',
        recordsPath: 'node_modules/.cache/hard-source/[confighash]/records.json',
        configHash: function (webpackConfig) {
          return require('node-object-hash')({ sort: false }).hash(webpackConfig);
        },
        environmentHash: {
          root: process.cwd(),
          directories: [],
          files: ['package-lock.json', 'yarn.lock'],
        },
      }),
    ]

  

相关文章:

  • 2021-12-07
  • 2021-06-04
  • 2021-12-14
  • 2021-05-19
  • 2021-06-19
  • 2021-08-04
猜你喜欢
  • 2021-07-31
  • 2021-10-11
  • 2021-09-04
  • 2022-12-23
  • 2021-11-18
  • 2021-08-26
  • 2021-05-20
相关资源
相似解决方案