HappyPack报错,提示:HappyPack: unable to locate the plugin list ?

新手上路,请多包涵

vuecli3.0创建的项目

配置了一些webpack的优化方案,其中就有用到一个叫HappyPack的插件,用来并发打包项目。但是配置完之后打包过程中报错。

报错信息:

Module build failed (from ./node_modules/_thread-loader@2.1.2@thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
HappyPack: unable to locate the plugin list! This most likely indicates an internal error.
    at PoolWorker.fromErrorObj (/Users/jalon/YHS/base-template/node_modules/_thread-loader@2.1.2@thread-loader/dist
/WorkerPool.js:258:12)
    at Object.HappyLoader (/Users/jalon/YHS/base-template/node_modules/_happypack@5.0.1@happypack/lib/HappyLoader.j
s:12:3)

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
 ERROR  Build failed with errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

vue.config.js

const HappyPack = require('happypack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const os = require('os');
const happyThreadPool = HappyPack.ThreadPool({
    size: os.cpus().length
});
module.exports = {
    productionSourceMap: false, // 生产打包时不输出map文件,增加打包速度
    chainWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            dllReference(config)
        }
    },
    configureWebpack: {
        module: {
            rules: [{
                    test: /\.js$/,
                    //把对.js 的文件处理交给id为happyBabel 的HappyPack 的实例执行
                    use: ['happypack/loader?id=happyBabel'],
                    //排除node_modules 目录下的文件
                    exclude: path.resolve(__dirname, 'node_modules'),
                },
                {
                    // 把对 .css 文件的处理转交给 id 为 css 的 HappyPack 实例
                    test: /\.css$/,
                    use: ExtractTextPlugin.extract({
                        use: ['happypack/loader?id=css'],
                    }),
                },
            ],
            
        },
        
        plugins: [
            new HappyPack({
                //用id来标识 happypack处理那里类文件
                id: 'happyBabel',
                //如何处理  用法和loader 的配置一样
                loaders: ['babel-loader?cacheDirectory'],
                //共享进程池
                threadPool: happyThreadPool,
            }),
            new HappyPack({
                id: 'css',
                // 如何处理 .css 文件,用法和 Loader 配置中一样
                loaders: ['css-loader'],
                threadPool: happyThreadPool,
            }),
            new ExtractTextPlugin({
                filename: `[name].css`,
            }),
        ],
        // 缩小你的JavaScript 生产环境删除console.log。
        optimization: {
            minimizer: [
                new TerserPlugin({
                    // pure_funcs: ['console.log'],
                    cache: true, //开启文件缓存
                    parallel: true, //开启并发 也也可以指定并发数
                }),
            ],
        },

    }

}

请教各位大神帮忙看下!

阅读 7.8k
5 个回答
新手上路,请多包涵

解决了吗,我也遇到了

新手上路,请多包涵

me too

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题