Skip to content

Not working with css-loader 7.1.2 #51

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

Open
diabhoil opened this issue Jun 3, 2024 · 6 comments
Open

Not working with css-loader 7.1.2 #51

diabhoil opened this issue Jun 3, 2024 · 6 comments

Comments

@diabhoil
Copy link

diabhoil commented Jun 3, 2024

When using the newest version of the css-loader (7.1.2) I could not generate the files correctly.

The *.sass.d.ts files where "empty":

// This file is automatically generated.
// Please do not change this file!
interface CssExports {
}
export const cssExports: CssExports;
export default cssExports;

After changing the version of css-loader to 6.8.1 everything was working like excepted. The output of the newest css-loader version is looking a bit different to the output of the older version.

@ilyabaykalov
Copy link

I encountered the same problem

@Andrei15193
Copy link

Same here, using version 6 fixed it for me. Thanks!

@kirilldronkin
Copy link

Starting with v7, you need to set modules.namedExport to false to keep it working

@Ch-Valentine
Copy link

if you need to use named export, you can use css-modules-dts-loader

@aidatorajiro
Copy link

aidatorajiro commented Apr 17, 2025

It worked after I set the css-loader option esModule to false.

It seems that this project requires css-loader exports an object containing CSS name fields as the default export. As of now, css-loader exports CSS name fields as individual exports (not default export). To deactivate this feature you need to add something like

{
test: /\.s[ac]ss$/i,
use: [
"style-loader",
"css-modules-typescript-loader",
{
  loader: "css-loader",
  options: {
    modules: true,
    esModule: false
  }
},
"sass-loader"
]
}

Or like

{
test: /\.s[ac]ss$/i,
use: [
"style-loader",
"css-modules-typescript-loader",
{
  loader: "css-loader",
  options: {
    modules: { mode: "local", namedExport: false },
  }
},
"sass-loader"
]
}

to the webpack module rules config.

@vcherevatyi-smartling
Copy link

{
        test: /\.module\.(css|postcss|pcss|scss|sass|less|styl|sss)$/i,
        use: [
          "style-loader",
          {
            loader: "css-modules-dts-loader",
            options: {
              // Convert CSS class names to camelCase (default: false)
              camelCase: true,
              // Quote style: "single" or "double" (default: "double")
              quote: "single",
              // Indentation style: "tab" or "space" (default: "space")
              indentStyle: "space",
              // Number of spaces if indentStyle is "space" (default: 2)
              indentSize: 2,
              // Mode: "emit" to generate or "verify" to check the file (default: "emit")
              mode: isProduction ? "verify" : "emit",
              // Sort the exported class names alphabetically (default: false)
              sort: true,
              // Use named exports instead of interface (default: true), should be the same with `css-loader` namedExport option
              namedExport: true,
              // Custom banner comment at the top of the file
              banner: "// This file is automatically generated.\n// Please do not change this file!"
            }
          },
          "css-loader"
        ]
      }

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

7 participants