Eladian
Eladian

Reputation: 958

webpack 4 using nodejs api - not creating vendors chunk

I have the following in my webpack 4 configuration:

 optimization: {
    runtimeChunk: 'single',
    splitChunks: {
      cacheGroups: {
        vendor: {
          test: /[\\/]node_modules[\\/]/,
          name: 'vendors',
          chunks: 'all'
        }
      }
    }
  }

running webpack from the command line, I see three files in the generated output:

However, on the server side I am using gulp and webpack 4 nodejs api to build the front end pragmatically:

function buildFrontEnd(config) {
  return function buildTheFrontEnd(cb) {
    webpack(config,cb);
  };
}

This results in the webpack build output being different from the command line output, missing the vendors.js file (as if running webpack pragmatically ignores splitChunks). Why is this?

Upvotes: 0

Views: 214

Answers (1)

Eladian
Eladian

Reputation: 958

Figured out the answer, turns out @babel/preset-env and @babel/preset-react had to be installed on the server and the build error wasn't propagating through gulp.

Upvotes: 1

Related Questions