neutrinojs / neutrino

Create and build modern JavaScript projects with zero initial configuration.
https://neutrinojs.org
Mozilla Public License 2.0
3.94k stars 213 forks source link

How to use plugin vendor-chunk? #811

Closed ArcherDs closed 6 years ago

ArcherDs commented 6 years ago

this is my config file:

module.exports = {
  options: {
    mains: {
      index: 'index',
      cf_index: 'cf_index',
    },
  },
  use: [
    [
      '@neutrinojs/airbnb',
      {
        eslint: {
          rules: {
            semi: 'off',
            'no-unused-vars': 'off',
            'jsx-a11y/anchor-is-valid': [
              'error',
              {
                components: ['Link'],
                specialLink: ['to'],
              },
            ],
          },
        },
      },
    ],
    [
      '@neutrinojs/react',
      {
        html: {
          title: 'title',
        },
        'vendor-chunk': true,
      },
    ],
    '@neutrinojs/jest',
  ],
};

I can't find out how to configure the chunk middleware to use the vendor-chunk plugin automatically create the vendor . Can anyone help?

edmorley commented 6 years ago

Hi! With Neutrino 8 (which uses webpack 3), the vendor handling isn't fully automatic. Neutrino does configure the various plugins required to get chunking working, but it also needs a fake vendor entrypoint to be defined in your .neutrinorc.js, which specifies which packages you'd like to be moved into the vendor chunk. See: https://neutrino.js.org/packages/react/#vendoring

Note that with webpack 4's new optimization.splitChunks feature this manual step won't be required. PR #809 is open to switch Neutrino to webpack 4, and is expected to be part of Neutrino 9.

ArcherDs commented 6 years ago

Thank you all for your quick and helpful response.

edmorley commented 6 years ago

You're welcome! :-)