React + Storybook + SCSS modules not working
See original GitHub issueDescribe the bug
Storybook doesn’t build/run with suggested changes for SCSS compatibility with modules.
Edit: Just tested without modules and changing file extension from css
to scss
also breaks it
To Reproduce
Create a new React app with Typescript (per React)
npx create-react-app my-app --template typescript
Add Storybook (per Storybook)
npx sb init
Add SCSS compatibility (per Storybook) by using SCSS preset
Here’s the repository.
After npm run storybook
, this is the error I get:
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: expected "{".
╷
2 │ import API from "!../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
│ ^
╵
src\stories\button.module.scss 2:98 root stylesheet
at processResult (C:\workspace\omegafox-components\node_modules\webpack\lib\NormalModule.js:758:19)
at C:\workspace\omegafox-components\node_modules\webpack\lib\NormalModule.js:860:5
at C:\workspace\omegafox-components\node_modules\loader-runner\lib\LoaderRunner.js:399:11
at C:\workspace\omegafox-components\node_modules\loader-runner\lib\LoaderRunner.js:251:18
at context.callback (C:\workspace\omegafox-components\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
at Object.loader (C:\workspace\omegafox-components\node_modules\sass-loader\dist\index.js:69:5)
at runNextTicks (node:internal/process/task_queues:61:5)
at processImmediate (node:internal/timers:437:9)
I’ve tried npx sb@next repro
but it didn’t work:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:25
Top Results From Across the Web
Import scss file is not working inside storybook file
If this doesn't work, try importing your scss file in preview.js of storybook config folder. .storybook > preview.js > import your CSS file;....
Read more >Storybook Addon Next
A no config Storybook addon that makes Next.js features just work in ... Module not found: Error: Can't resolve [package name] ... Css/Sass/Scss...
Read more >Can't get Storybook to work with CSS Modules using SCSS ...
I'm having problems getting Storybook to work with my react.js project when I'm using CSS Modules which contain SCSS. Below is my webpack.copy.js...
Read more >storybook-css-modules-preset - npm
Start using storybook-css-modules-preset in your project by running `npm i storybook-css-modules-preset`. There are 17 other projects in the ...
Read more >storybook-css-modules-preset - npm package - Snyk
The npm package storybook-css-modules-preset was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just tried again from scratch, repeating step by step from Storybook docs and it’s still not working. Tried downgrading
sass-loader
to 10.2.1, still not working.It’s a brand new installation of React + Storybook with SASS following the app documentation and it’s broken, it’s kinda nuts that this is still on “needs triage” tag 1 month after the bug was created.
After downgrade still same error