Christopher
Christopher

Reputation: 21

TypeError: Cannot read property 'splitChunks' of undefined - Webpack

I just replace in my webpack.dev.config.js the :

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

by

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

Now when I want to use yarn start in my terminal I have the issue below: TypeError: Cannot read property 'splitChunks' of undefined

How can I fix this please?

Thanks in advance for your help.

Upvotes: 2

Views: 2385

Answers (1)

Tony Nguyen
Tony Nguyen

Reputation: 11

Fix it: plugins:

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

Upvotes: 1

Related Questions