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

[Bug]: Scss Module not work #6350

Closed
childrentime opened this issue Apr 24, 2024 · 1 comment
Closed

[Bug]: Scss Module not work #6350

childrentime opened this issue Apr 24, 2024 · 1 comment
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.

Comments

@childrentime
Copy link

childrentime commented Apr 24, 2024

System Info

System:
OS: macOS 14.1
CPU: (8) arm64 Apple M3
Memory: 65.58 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
Yarn: 1.22.21 - ~/.nvm/versions/node/v18.12.1/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
pnpm: 8.15.5 - ~/.nvm/versions/node/v18.12.1/bin/pnpm
Watchman: 2024.04.15.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 124.0.6367.62
Edge: 124.0.2478.51
Safari: 17.1
npmPackages:
@rspack/cli: 0.6.2 => 0.6.2
@rspack/core: 0.6.2 => 0.6.2
@rspack/plugin-react-refresh: 0.6.2 => 0.6.2

Details

使用rspack-cli创建一个脚手架项目,安装sass sass-loader,参考https://www.rspack.dev/zh/guide/tech/css#sass,修改rspack.config.js。然后将 App.css文件修改为 App.module.scss 文件,并且使用 import styles from "./App.module.scss";引入。运行项目之后控制台报错,因为styles的值是 undefined

image

Reproduce link

https://github.com/childrentime/rspack-project

Reproduce Steps

pnpm i
pnpm dev

Tasks

Preview Give feedback
No tasks being tracked yet.
@childrentime childrentime added bug Something isn't working pending triage The issue/PR is currently untouched. labels Apr 24, 2024
@SyMind
Copy link
Member

SyMind commented Apr 25, 2024

You should use with namespace import like import * as styles from "./App.module.scss";.

If you want to use with default import, should set module.parser['css/auto'].namedExports=false.

You can get more detail in here: https://webpack.js.org/configuration/module/#moduleparser

@SyMind SyMind closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage The issue/PR is currently untouched.
Projects
None yet
Development

No branches or pull requests

2 participants