question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React + Storybook + SCSS modules not working

See original GitHub issue

Describe 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: image

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:11
  • Comments:25

github_iconTop GitHub Comments

12reactions
FelipeZNascimentocommented, Apr 19, 2022

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.

8reactions
auri179commented, Apr 6, 2022
"sass": "^1.49.9",
"sass-loader": "^10.2.1",
"style-loader": "^3.3.1",
"typescript": "~4.3.5"

After downgrade still same error

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found