Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 网页包忽略生产构建的分块_Javascript_Webpack - Fatal编程技术网

Javascript 网页包忽略生产构建的分块

Javascript 网页包忽略生产构建的分块,javascript,webpack,Javascript,Webpack,我有一个网页包配置,它正在我的项目中拆分我的代码。我试图做的是忽略分块,如果它是一个生产构建,则生成一个文件 这是我的网页包配置文件: 这是我的index.js,因为正在发生分块: if (typeof require.ensure !== `function`) require.ensure = (d, c) => c(require); // mocha test runner polyfill /** * require.ensure allows asynchronous

我有一个网页包配置,它正在我的项目中拆分我的代码。我试图做的是忽略分块,如果它是一个生产构建,则生成一个文件

这是我的网页包配置文件:

这是我的index.js,因为正在发生分块:

if (typeof require.ensure !== `function`) require.ensure = (d, c) => c(require);  // mocha test runner polyfill

/**
 * require.ensure allows asynchronous chunk loading of the component, which means an extra HTTP hop to download the component,
 * in exchange of smaller initial download footprint.
 * - Use require.ensure for components that are least frequently used
 * - Use require.ensure for components that import libraries that are large in size
 */
export function lookup(componentName, callback) {
    switch (componentName) {
        // ============================== Components ===============================
        case 'dD':
            callback(require('./components/dD'));
            break;
        case 'eBL':
            callback(require('./components/eBL'));
            break;
        case 'essay':
            callback(require('./components/essay'));
            break;
        case 'hSM':
            require.ensure([], require => callback(require('./components/hSM')));
            break; 
这就是它现在产生的结果:

如果(iProduction)为true,请帮助我生成单个文件

我已经尝试删除CommonChunks插件和MinChunkSizePlugin,如果是我的产品,但是这些块仍然在发生。我也试着删除

jsonpFunction: `jsonpFunction${jsonpPackageName}`,
    chunkFilename: `${packageName}/${packageName}-[id].js`,
但它仍然会生成0.0.js、1.1.js、2.2.js


请告诉我我错过了什么。谢谢

您可以通过将最大块数限制为1来禁用代码拆分,方法是:


您可以通过以下方法将最大块数限制为1来禁用代码拆分:


嘿,这将生成两个文件cas-core-renderer.js和cas-core-renderer-0.js。我尝试将它设置为maxChunks:0,但我认为它禁用了插件,因为它再次生成了5个文件。谢谢你的帮助!嘿,这将生成两个文件cas-core-renderer.js和cas-core-renderer-0.js。我尝试将它设置为maxChunks:0,但我认为它禁用了插件,因为它再次生成了5个文件。谢谢你的帮助!
plugins: [
    new webpack.optimize.LimitChunkCountPlugin({
        maxChunks: 1
    });
]