Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explain difference to rollupOptions.output.manualChunks #17

Open
milahu opened this issue Dec 5, 2022 · 2 comments
Open

explain difference to rollupOptions.output.manualChunks #17

milahu opened this issue Dec 5, 2022 · 2 comments

Comments

@milahu
Copy link

milahu commented Dec 5, 2022

what is the difference to rollupOptions.output.manualChunks?

vite.config.js manualChunks

import { defineConfig } from "vite"

export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('/node_modules/@codemirror/')) {
            return 'codemirror';
          }
          console.log("id", id)
          if (id.includes('/node_modules/')) {
            return 'vendor';
          }
        },
      }
    },
  },
})

vite.config.js chunkSplitPlugin

import { defineConfig } from "vite"
import { chunkSplitPlugin } from 'vite-plugin-chunk-split'

export default defineConfig({
  plugins: [
    chunkSplitPlugin({
      //strategy: 'default',
      customSplitting: {
        'codemirror': [/\/node_modules\/@codemirror\//],
      }
    })
  ],
})

result manualChunks

dist/index.js        11.26 KiB / gzip: 4.35 KiB
dist/vendor.js       187.72 KiB / gzip: 40.70 KiB
dist/codemirror.js   369.08 KiB / gzip: 116.12 KiB

result chunkSplitPlugin

dist/index.js                 11.29 KiB / gzip: 4.36 KiB
dist/vendor.js                187.66 KiB / gzip: 40.72 KiB
dist/codemirror.js            369.08 KiB / gzip: 116.12 KiB
dist/__commonjsHelpers__.js   0.13 KiB / gzip: 0.09 KiB
@sanyuan0704
Copy link
Owner

Yes, the feature is by design to avoid circular dependency problem in manualChunks

@milahu
Copy link
Author

milahu commented Dec 5, 2022

i fixed my customSplitting regex
now manualChunks and chunkSplitPlugin give the same result

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

No branches or pull requests

2 participants