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

Can't use output.manualChunks during Nuxt build #50

Open
richardeschloss opened this issue Dec 30, 2021 · 1 comment
Open

Can't use output.manualChunks during Nuxt build #50

richardeschloss opened this issue Dec 30, 2021 · 1 comment

Comments

@richardeschloss
Copy link

richardeschloss commented Dec 30, 2021

Environment


  • Operating System: Linux
  • Node Version: v16.13.1
  • Nuxt Version: 2.16.0-27347055.777a4b7f
  • Package Manager: [email protected]
  • Bundler: Webpack
  • User Config: components, bridge, vite, css, target, head, plugins, buildModules, stories, telemetry
  • Runtime Modules: -
  • Build Modules: @nuxt/[email protected]

Reproduction

Attempt to specify manualChunks in nuxt.config:

  vite: {
    build: {
      rollupOptions: {
        output: {
          inlineDynamicImports: false, // <-- I get manualChunks, but not all the ones I specify 
          manualChunks: {
            utils: ['./lib/utils.js'] // example. utils will correctly be created in .nuxt/dist/server/chunks, but never transferred to .output/server/chunks
          }
        }
      }
    },
  }

Describe the bug

When attempting to build Nuxt application which may work perfectly fine in development mode (nuxi dev), actually building the application using nuxi build will finally see and warn about chunk sizes being too large. This is the typical warning message that appears:

(!) Some chunks are larger than 500 KiB after minification. Consider:

I have tried to use dynamic imports as much as possible, but this is not always ideal because then it requires so much code refactoring and lose the benefit of top-level imports. I'd also prefer not to increase the chunk size warning limit since the warning should probably not be ignored. So, I try specify manualChunks only to encounter the following error message:

Invalid value for option "output.manualChunks" - this option is not supported for "output.inlineDynamicImports".

It seems like I can't specify those options. It would be nice if I could.

Additional context

No response

Logs

No response

@fabiwlf
Copy link

fabiwlf commented Jan 7, 2022

@richardeschloss Seems to not work for server build at the moment. But just using a hook like this works at least for building the client dependencies.

hooks: {
    "vite:extendConfig"(
      clientConfig,
      { isClient, isServer }
    ) {
      if (isClient) {
        clientConfig.build.rollupOptions.output.manualChunks = {
          "entry-custom": [
            "nuxt3/dist/app/entry.mjs",
            "nuxt3/dist/app/bootstrap.mjs",
          ],
          "bootstrap-custom": [
            "./components/Header"
            "./pages/index"
          ],
        };
    },
  },

@danielroe danielroe transferred this issue from nuxt/framework Apr 13, 2022
@danielroe danielroe removed the bridge label Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants