HappyPack报错记录:HappyPack: unable to locate the plugin list!

happyPack报错:HappyPack: unable to locate the plugin list! This most likely indicates an internal error.

原代码:

configureWebpack: config => {
  //happypack - js 部分
  config.module.rules.push({
    test: /\.js$/,
    loader: 'happypack/loader?id=happyBabel',
  })
  config.plugins.push(new HappyPack({
    id: 'happyBabel',
    loaders: [{
      loader: 'babel-loader?cacheDirectory=true',
    }],
    threadPool: happyThreadPool,
    //允许 HappyPack 输出日志
    verbose: true,
  })
}

尝试后发现应该是js的rule部分有问题,去掉上面写在configureWebpack中的rule部分,修改为在chainWebpack中清除js的rule规则后,再进行happypack配置。

修改后代码:

//happyPack - js 部分
chainWebpack: config => {
  const jsRule = config.module.rule('js');
  jsRule.uses.clear();
  jsRule.use('happypack/loader?id=happyBabel')
        .loader('happypack/loader?id=happyBabel')
        .end();
}
configureWebpack: config => {
  //happypack - js 部分
  config.plugins.push(new HappyPack({
    id: 'happyBabel',
    loaders: [{
      loader: 'babel-loader?cacheDirectory=true',
    }],
    threadPool: happyThreadPool,
    //允许 HappyPack 输出日志
    verbose: true,
  })
}

你可能感兴趣的:(vue.jswebpack)