Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

unable to locate the plugin list! This most likely indicates an internal error. #273

Open
wywzixin opened this issue Sep 27, 2020 · 5 comments

Comments

@wywzixin
Copy link

wywzixin commented Sep 27, 2020

微信截图_20200927203739

@wywzixin
Copy link
Author

I don't know what happened to it. Can you help me look at it

@amireh
Copy link
Owner

amireh commented Sep 27, 2020

Can you list your Webpack version and the config?

@wywzixin
Copy link
Author

wywzixin commented Sep 28, 2020

[email protected]
"happypack": "^5.0.1",
use vue-cli4

const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('terser-webpack-plugin');
const HtmlWebpackTagsPlugin = require('html-webpack-tags-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const HappyPack = require('happypack')
const os = require('os')
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const chalk = require('chalk');
const happyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length })

const isProd = process.env.NODE_ENV === 'production';
module.exports = {
publicPath: isProd ? ' ./' : '/',
devServer: {
},
configureWebpack: config => {
config.module.unknownContextCritical = false;
config.resolve.alias = {
'@': path.resolve(__dirname, 'src'),
C: path.resolve(__dirname, 'src/components'),
S: path.resolve(__dirname, 'src/service'),
U: path.resolve(__dirname, 'src/utils'),
};
config.entry = isProd
? {
customSource: './src/CustomSource/CustomSource.js',
app: './src/main.js',
}
: {
Cesium: './ThirdParty/CesiumSource.js',
customSource: './src/CustomSource/CustomSource.js',
app: './src/main.js',
};

    config.plugins.push(
        new webpack.DefinePlugin({
            CESIUM_BASE_URL: JSON.stringify('./Cesium/')
        }),
        new CopyWebpackPlugin([
            {
                from: './node_modules/cesium/Build/Cesium',
                to: 'Cesium',
            },
        ]),
        new webpack.ProvidePlugin({
            jQuery: 'jquery',
            $: 'jquery',
        }),
        new HappyPack({
            id: 'happyBabel',
            loaders: [{
                loader: 'babel-loader?cacheDirectory=true',
            }],
            threadPool: happyThreadPool,
            verbose: true,
        })
    );

    if (isProd) {
        config.module.rules.push({
            test: /\.js$/,
            loader: 'happypack/loader?id=happyBabel',
            exclude: /node_modules/
        });
        // 为生产环境修改配置...
        config.optimization = {
            minimizer: [
                new UglifyJsPlugin({
                    terserOptions: {
                        warnings: false,
                        compress: {
                            drop_debugger: true,
                            drop_console: true,
                            pure_funcs: ['console.log'],
                        },
                        output: {
                            comments: false,
                        },
                    },
                    sourceMap: false,
                    parallel: true,
                }),
            ],
            splitChunks: {
                chunks: 'all',
                minSize: 300000,
                maxSize: 10000000,
                cacheGroups: {
                    vendors: {
                        test: /[\\/]node_modules[\\/]/, // 匹配node_modules目录下的文件
                        priority: -10, // 优先级配置项
                    },
                    default: {
                        minChunks: 2,
                        priority: -20, // 优先级配置项
                        reuseExistingChunk: true,
                    },
                },
            },
        };
        config.plugins.push(
            new HtmlWebpackPlugin({
                filename: './index.html',
                template: './public/index.html',
            }),

            new HtmlWebpackTagsPlugin({
                append: false,
                scripts: 'Cesium/Cesium.js',
            }),

            new HtmlWebpackTagsPlugin({
                append: false,
                links: 'Cesium/Widgets/widgets.css',
            }),
            // new BundleAnalyzerPlugin(),
            new CompressionPlugin({
                filename: '[path].gz[query]',
                algorithm: 'gzip',
                test: /\.js$|\.css$|\.html$/,
                threshold: 102400,
                minRatio: 0.8,
                deleteOriginalAssets: true,
            }),
            // new HappyPack({
            //     // 3) re-add the loaders you replaced above in #1:
            //     loaders: [ 'babel-loader?presets[]=es2015' ],
            //     threadPool: happyThreadPool,
            //     id: 'babel'
            //   }),
            // new HappyPack({
            //     //用id来标识 happypack处理那里类文件
            //     id: 'happyBabel',
            //     //如何处理  用法和loader 的配置一样
            //     loaders: [{
            //         loader: 'babel-loader?cacheDirectory=true',
            //     }],
            //     //共享进程池
            //     threadPool: happyThreadPool,
            //     //允许 HappyPack 输出日志
            //     verbose: true,
            // }),
            new ProgressBarPlugin({
                format: ' build [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds)',
                clear: false
            })
        );
    } else {
        // 为开发环境修改配置...
        config.devtool = 'eval-source-map';
        config.plugins.push(
            new HtmlWebpackPlugin({
                filename: './index.html',
                template: './public/index.html',
            }),
            new HtmlWebpackTagsPlugin({
                append: false,
                links: './Cesium/Widgets/widgets.css',
            })
        );
    }
},
chainWebpack: config => {
    const oneOfsMap = config.module.rule('scss').oneOfs.store;
    oneOfsMap.forEach(item => {
        item.use('sass-resources-loader')
            .loader('sass-resources-loader')
            .options({
                resources: './src/style/public.scss',
            })
            .end();
    });
    config
        .plugin('webpack-bundle-nalyzer')
        .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin);
    return config;
},

};

@wywzixin
Copy link
Author

Can you list your Webpack version and the config?
Is it a version issue?

@MyCodeMyWorld
Copy link

Has the problem been solved?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants