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

Unable to configure webpack dev server. #71947

Open
dwjohnston opened this issue Oct 28, 2024 · 0 comments
Open

Unable to configure webpack dev server. #71947

dwjohnston opened this issue Oct 28, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc. Documentation Related to Next.js' official documentation. Webpack Related to Webpack with Next.js.

Comments

@dwjohnston
Copy link

dwjohnston commented Oct 28, 2024

Link to the code that reproduces this issue

https://github.com/dwjohnston/nextjs-webpack-dev-server

To Reproduce

  1. Start the application (npm run dev), open browser window to running application
  2. Open the dev tools, network tab, inspect the headers of the page.js file

The reproduction attempts to configure the webpack dev server by adding:

  webpack: (config) => {
    if (!config.devServer){
      config.devServer = {};
    }

    config.devServer.headers = () => {
      return [{
        key: "hello", 
        value: "world"
      }]
    }
    return config;   
  }

To next.config.js

The NextJS documentation does not indicate that webpack dev server can not be configured this way, nor does it indicate an alternative mechanism for configuring.

Current vs. Expected behavior

Expected behaviour:

The page.js resource should have the header `hello: world'

Actual behaviour:

The resouce does not have the expected header.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Wed Jul 31 20:49:39 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 8
Binaries:
  Node: 22.10.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 8.9.0
Relevant Packages:
  next: 15.0.1 // Latest available version is detected (15.0.1).
  eslint-config-next: 15.0.1
  react: 19.0.0-rc-69d4b800-20241021
  react-dom: 19.0.0-rc-69d4b800-20241021
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Developer Experience, Documentation, Webpack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

The purpose of this, is investigating a performance optimisation - basically implementing something similar to Vite's prebundling.

The issue I have is our development bundle is very large (15MB or so) and this takes about 1-2s to download. I want to use Webpack's SplitChunksPlugin to split out large vendor bundles, and also apply an immutable cache header to them.

The webpack configuration for splitting the chunks is being respected, but I can't apply the immutable cache header.

@dwjohnston dwjohnston added the bug Issue was opened via the bug report template. label Oct 28, 2024
@github-actions github-actions bot added Developer Experience Issues related to Next.js logs, Error overlay, etc. Documentation Related to Next.js' official documentation. Webpack Related to Webpack with Next.js. labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc. Documentation Related to Next.js' official documentation. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant