Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

How to use plugin vendor-chunk? #811

Closed
ArcherDs opened this issue Apr 22, 2018 · 3 comments
Closed

How to use plugin vendor-chunk? #811

ArcherDs opened this issue Apr 22, 2018 · 3 comments

Comments

@ArcherDs
Copy link

ArcherDs commented Apr 22, 2018

  • What version of Neutrino are you using?
    latest
  • Are you trying to use any presets? If so, which ones, and what versions?
    "@neutrinojs/airbnb": "^8.2.2",
    "@neutrinojs/jest": "^8.2.2",
    "@neutrinojs/react": "^8.2.2",
    "neutrino": "^8.2.2"
  • Are you using the Yarn client or the npm client? What version?
    yarn 1.6.0
  • What version of Node.js are you using?
    v9.11.1
  • What operating system are you using?
    mac
  • What did you do?
    Try to creates a separate file/chunk consisting of common modules shared between multiple entry points.

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
Copy link
Member

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
Copy link
Author

Thank you all for your quick and helpful response.

@edmorley
Copy link
Member

You're welcome! :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants