-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
CSS-Modules don't work with storybook #2320
Comments
That script extends/overrides the webpack config of CRA. Provide storybook with the relevant webpack config, and it should work too. |
Note that you don't have to use Full Control Mode. You can just set the options for e.g., in
|
Thanks for posting your working solution @cdtinney |
@cdtinney thanks man you are a lifesaver |
I have ecountered that const path = require('path');
// Export a function. Accept the base config as the only param.
module.exports = async ({ config, mode }) => {
// `mode` has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.
// Make whatever fine-grained changes you need
config.module.rules.push({
test: /\.scss$/,
loaders: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
modules: {
mode: 'local',
localIdentName: '[path][name]__[local]--[hash:base64:5]',
// localIdentName: '[sha1:hash:hex:4]',
context: path.resolve(__dirname, 'src'),
hashPrefix: 'my-custom-hash',
},
},
},
require.resolve('sass-loader')
],
});
// Return the altered config
return config;
}; |
is there a way to use all style formats like ( .css, .scss, .module.css, .module.scss ) in a single project, I tried it to do like the code shown below, but not working. main.js module.exports = { webpackFinal: async (config, { configType }) => {
}, |
If smb still has problem of using css-modules in storybook with cra or nextjs this solved the issue for me - https://github.com/Negan1911/storybook-css-modules-preset |
If you use https://github.com/ro-savage/react-scripts-cssmodules with create-react-app to incorporate CSS-Modules, storybook does not register the styles. The styles work perfectly when running directly on react.
The text was updated successfully, but these errors were encountered: