Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
143 views
in Technique[技术] by (71.8m points)

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

vuecli3.0创建的项目

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

报错信息:

Module build failed (from ./node_modules/[email protected]@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/[email protected]@thread-loader/dist
/WorkerPool.js:258:12)
    at Object.HappyLoader (/Users/jalon/YHS/base-template/node_modules/[email protected]@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, //开启并发 也也可以指定并发数
                }),
            ],
        },

    }

}

请教各位大神帮忙看下!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

解决了吗,我也遇到了


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...