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

When I added the rules for node_modules in next.config.js, I encountered the issue of Built-in CSS support being disabled. #75258

Closed
Zzzccs123 opened this issue Jan 24, 2025 · 0 comments
Labels
CSS Related to CSS.

Comments

@Zzzccs123
Copy link

Link to the code that reproduces this issue

https://github.com/Zzzccs123/next-active-class-name-app

To Reproduce

// next.config.js

const nextConfig = {
  webpack: (config, { dev, defaultLoaders }) => {
    /* If execute it, an error will occur.  */
    // config.module.rules.push({
    //   test: /\.js|jsx$/,
    //   include: (modPath) => {
    //     return modPath.indexOf('node_modules') === -1
    //   },
    //   use: defaultLoaders.babel
    // });
    return config
  },
};

module.exports = nextConfig;

Both global.module.css and global.css are just regular CSS code.

// app/page.tsx
import Nav from "../components/Nav";
import './global.module.css'
import './global.css'

const IndexPage = () => (
  <>
    <Nav />
    <p>Hello, I'm the index page</p>
  </>
);

export default IndexPage;

Current vs. Expected behavior

I want to use babel-loader to transform the code in node_modules, aiming for compatibility with a wider range of browser versions.

So, I added rules for node_modules in next.config.js without modifying any css-related rules. However, I encountered an issue where Built-in CSS support is being disabled.

Exception Details:

Image

Expected Behavior:
No errors will occur.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:46 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 18.19.1
  npm: 9.8.1
  Yarn: 1.22.22
  pnpm: 9.3.0
Relevant Packages:
  next: 15.1.6 // Latest available version is detected (15.1.6).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.7.3
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 build (local)

Additional context

No response

@github-actions github-actions bot added the CSS Related to CSS. label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Related to CSS.
Projects
None yet
Development

No branches or pull requests

1 participant