We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm not able to import the styles default module when using .scss
styles
.scss
This is my webpack config:
{ test: /\.module\.scss$/, use: [ 'style-loader', { loader: 'css-loader', options: { modules: { auto: true, localIdentName: '[name]__[local]___[hash:base64:5]', }, }, }, { loader: 'sass-loader', options: { implementation: require( 'sass' ), }, }, ], },
so when I import the default module:
import styles from './style.module.scss';
... styles is undefined.
However, it's possible to reach it by importing all modules:
import * as styles from './style.module.scss';
Now, styles is defined and contains all classes IDs:
On the other hand, when using simply css files, it works as expected, without any specific settings:
css
import styles from './style.module.css';
How can I export the module straight in the default export using scss?
https://stackblitz.com/edit/github-x7muknfl?file=.storybook%2Fmain.ts,package.json&preset=node
in the main.js file:
webpackFinal: async ( config ) => { config.module.rules.push( { test: /\.scss$/, oneOf: [ { test: /\.module\.scss$/, use: [ 'style-loader', { loader: 'css-loader', options: { modules: { auto: true, localIdentName: '[name]__[local]___[hash:base64:5]', }, }, }, { loader: 'sass-loader', options: { implementation: require( 'sass' ), }, }, ], }, { use: [ 'style-loader', 'css-loader', { loader: 'sass-loader', options: { implementation: require( 'sass' ), }, }, ], }, ], } ); return config; },
style.scss
style
import styles from './style.module.scss'; console.log( { styles } ); // `styles` is undefined
import * as styles from './style.module.scss'; console.log( { styles } ); // now `styles` contains class IDs
Storybook Environment Info: System: OS: macOS 15.1.1 CPU: (16) arm64 Apple M4 Max Shell: 5.9 - /bin/zsh Binaries: Node: 18.3.0 - ~/.nvm/versions/node/v18.3.0/bin/node npm: 8.11.0 - ~/.nvm/versions/node/v18.3.0/bin/npm <----- active Browsers: Chrome: 131.0.6778.109 Safari: 18.1.1 npmPackages: @storybook/addon-essentials: ^8.4.7 => 8.4.7 @storybook/addon-interactions: ^8.4.7 => 8.4.7 @storybook/addon-onboarding: ^8.4.7 => 8.4.7 @storybook/addon-webpack5-compiler-swc: ^1.0.5 => 1.0.5 @storybook/blocks: ^8.4.7 => 8.4.7 @storybook/react: ^8.4.7 => 8.4.7 @storybook/react-webpack5: ^8.4.7 => 8.4.7 @storybook/test: ^8.4.7 => 8.4.7 eslint-plugin-storybook: ^0.11.1 => 0.11.1 storybook: ^8.4.7 => 8.4.7
No response
The text was updated successfully, but these errors were encountered:
LESS also has this bug
Sorry, something went wrong.
https://github.com/Negan1911/storybook-css-modules-preset/blob/master/index.js
this will solve your problem
No branches or pull requests
Describe the bug
I'm not able to import the
styles
default module when using.scss
This is my webpack config:
so when I import the default module:
...
styles
is undefined.However, it's possible to reach it by importing all modules:
Now,
styles
is defined and contains all classes IDs:On the other hand, when using simply
css
files, it works as expected, without any specific settings:How can I export the module straight in the default export using scss?
Reproduction link
https://stackblitz.com/edit/github-x7muknfl?file=.storybook%2Fmain.ts,package.json&preset=node
Reproduction steps
in the main.js file:
style.scss
filestyle
:System
Additional context
No response
The text was updated successfully, but these errors were encountered: