【问题标题】:TypeError: Cannot read property 'splitChunks' of undefined - WebpackTypeError:无法读取未定义的属性“splitChunks” - Webpack
【发布时间】:2018-07-30 13:43:04
【问题描述】:

我只是在我的 webpack.dev.config.js 中替换:

new webpack.optimize.CommonsChunkPlugin({ name: 'common', }),

new webpack.optimization.splitChunks({ name: 'common' }),.

现在,当我想在终端中使用 yarn start 时,我遇到了以下问题: TypeError: Cannot read property 'splitChunks' of undefined

请问我该如何解决这个问题?

提前感谢您的帮助。

【问题讨论】:

    标签: webpack config


    【解决方案1】:

    修复它: 插件:

    [
        new HTMLWebpackPlugin({
            title: 'Code splitting'enter code here
        }),
    ],
    optimization: {
        splitChunks: {
            chunks: 'all'
        }
    },
    output: {
        filename: '[name].bundle.js',
        path: path.resolve(__dirname, 'dist')
    }
    

    【讨论】:

    • 感谢您的回答!我会努力做到的。
    • 注意:Webpack 版本 >= 4. :)))
    • 如果我在我的代码中根本没有使用 splitChunks 就收到此错误,这意味着什么?它似乎来自 next-css
    猜你喜欢
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    • 2019-02-12
    • 2021-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多