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

打出来的vendor包会把当前模块没有引入的node_modules下的项目也打进去 #9

Open
goccult opened this issue Sep 22, 2022 · 2 comments

Comments

@goccult
Copy link

goccult commented Sep 22, 2022

当前项目是一个多入口的项目

     rollupOptions: {
        input: {
          main: resolve(__dirname, 'src/index.html'),
          fastUpload: resolve(__dirname, 'src/fastUpload/index.html'),
          dataReport: resolve(__dirname, 'src/dataReport/index.html'),
          download: resolve(__dirname, 'src/download/index.html'),
        },
      },

采用的配置

      chunkSplitPlugin({
        strategy: 'default',
        customSplitting: {
          // `react` and `react-dom` 会被打包到一个名为`render-vendor`的 chunk 里面(包括它们的一些依赖,如 object-assign)
          'react-vendor': ['react', 'react-dom'],
          'lodash-vendor': ['lodash'],
        }
      })

其中node_modules里的 echarts只被dataReport模块依赖,但是也会被打进vendor包里,在index页面加载时也会被加载进去。
image

如果只用rullupOptions配置是可以做到echarts只被dataReport模块引入的,但是会没有了vendor包

        output: {
          // manualChunks 配置
          manualChunks: {
            'react-vendor': ['react', 'react-dom'],
            'lodash-vendor': ['lodash'],
          },
        },

image

期待的效果是vendor包中只存在当前模块有依赖的项目。

@mmdctjj
Copy link

mmdctjj commented Jul 11, 2023

我也遇到了这个问题

@ffio
Copy link

ffio commented Apr 24, 2024

请问已经解决了么?求个方案,谢谢

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

3 participants