-
-
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
Import Less not work. #9796
Comments
I find that less file was handled with file-loader or url-loader. But I don't know how to fix this. 😢 import styles from './index.less'
console.log(style) // it's a url path |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
I've been looking for the answers for a similar problem. In @storybook/preset-ant-design it mentions configuring CRA to exclude less from the file loader.
May help. |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
I have the same problem. I use |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
i have the same problem |
Here's an example using craco and semantic UI
|
because cra's file-loader intercept all other file, so the less file can't go into less-loader; |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
same here |
Hi everyone, i cant integrate less into my react app |
we're also unable to import styles into our components in storybook using |
I meet this problem too. This is my resolution. {
"@storybook/react": "^6.5.16"
"@storybook/manager-webpack5": "^6.5.16"
"@storybook/builder-webpack5": "^6.5.16",
"less": "^4.1.3",
"less-loader": "^11.1.0",
"css-loader": "^6.7.3"
} // main.js
webpackFinal: async (config) => {
const lessLoaderChain = {
test: /\.less$/,
use: [
'style-loader',
'css-loader',
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true
}
}
}
]
}
const oneOfRule = config.module.rules.find(rule => !!rule.oneOf);
if (oneOfRule) {
oneOfRule.oneOf.unshift(lessLoaderChain);
} else {
config.module.rules.unshift(lessLoaderChain);
}
return config;
}, |
Describe the bug
Can't import less file in JavaScript.
To Reproduce
Steps to reproduce the behavior:
cd <dir>
, then Executenpx -p @storybook/cli sb init
yarn add -D less less-loader
.storybook/main.js
:Expected behavior
Import Less file successfully into story, then show styles defined by the less file.
Screenshots
I know the webpack doesn't load less finally by devtools
However, when I wrote down
options.errorFlag = true
in rules delibrately, it throw a loader error, which proves it has already parse the imported less file. Why? 🤔Code snippets
.storybook/main.js
System:
Additional context
Using the newest stable 5.3.12.
If I change the
.less
extension to.css
, it works! Why not less?The text was updated successfully, but these errors were encountered: