Skip to content

Regression in Next.js 16.0.1: sassOptions.additionalData causes error when using --webpack flag, worked in 15.5.2 #85870

@GlebKodrik

Description

@GlebKodrik

Link to the code that reproduces this issue

https://github.com/GlebKodrik/scss-nextjs/tree/master

To Reproduce

  1. Use Next.js version 16.0.1 with the --webpack flag.
  2. Add the following configuration to next.config.ts:
sassOptions: {
  additionalData: '@use "app/styles" as *;',
},
  1. Start the development server using next dev or make a production build with next build.
  2. An error occurs during the build process.
Can't find stylesheet to import.
  ╷
1 │ @use "app/styles" as *;

Current vs. Expected behavior

Expected Behavior: The configuration with sassOptions.additionalData should work identically to version 15.5.2, where it successfully injects the global SCSS module.

Current Behavior: In version 16.0.1, adding the sassOptions.additionalData line immediately causes a build error. This is a regression, as the same configuration works without any issues in version 15.5.2.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0
Binaries:
  Node: 20.17.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 9.10.0
Relevant Packages:
  "next": "^16.0.1",
  "react": "19.1.0",
  "react-dom": "19.1.0"
Next.js Config:
  output: N/A

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

CSS

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

next dev (local), next build (local)

Additional context

The issue is specific to the new version 16.0.1. Rolling back to 15.5.2 resolves the problem immediately.

The project uses the --webpack configuration flag.

The goal of the additionalData option is to globally import an SCSS module (app/styles) into every Sass file in the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions