0

The following configuration will create client.js and vendors.js.

example

Entry

entry: {
  'client': './client.js',
  'vendors' ['jquery' , 'react']
}

Plugin

     new CommonsChunkPlugin({
        name: 'client',
        minChunks: Infinity
     }),
     new CommonsChunkPlugin({
        name: 'vendors',
        chunks: ['client'],
        minChunks: Infinity
     })

To make it work, I need to add the client.js and vendor.js files in the HTML, otherwise i will get the error: Uncaught ReferenceError: webpackJsonp is not defined.

How can I include only the client.js file in the index.html and make it require the vendors.js file automatically?

I would like to obtain the same behaviour that I get when I split the code with require.ensure.

DangerLine
  • 23
  • 4
  • For code splitting automatically & then auto loading, you might want to look at the require.ensure() method. If you do this, you just have the one entry point, and leave the rest to webpack. – Keith Oct 07 '16 at 09:54
  • Thanks for the answer, I already knew that. But is it possible to do the explicit splitting from the entry and the auto loading script? – DangerLine Oct 07 '16 at 10:13
  • Not that I know off, sorry. Someone might have created a plugin who knows??. The problem is if your not using require.ensure(), there is no way a script could auto-load a previous one without making the current one load the previous script in synchronous (blocking mode), and that's not really ideal. – Keith Oct 07 '16 at 10:19

0 Answers0