storybook: Does not support less
I am trying to use storybook with antd but in antd it is using less so I have this error:
ERROR in ./~/antd/lib/style/index.less
Module parse failed: D:\Projects\btfWeb2\node_modules\antd\lib\style\index.less Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
Can anyone help me adding less to storybook ? Thanks a lot
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 22 (4 by maintainers)
This was very helpful. Being that my project is via
create-react-app, I did the following to get storybook working with LESSCSS support:Install webpack loaders:
Create a new, local webpack config at
.storybook/webpack.config.jswith the following contents:@Peakdrum you can use this:
{ test: /\.less$/, loaders: [ 'style-loader', 'css-loader', 'less-loader' ] }Hi @Peakdrum This error message refers to webpack loaders. You need to set one to support LESS files.
Check the storybook documentation about custom webpack config. There is an example on this page about how to support SASS. Supporting LESS will be probably very similar, maybe with less-loader.
Hope this help!
I’m seeing a less issue 😦
It’s still failing, even after following the docs and replacing for ‘less’
I also needed antd to work with storybook and found I needed javascriptEnabled option also:
~ https://stackoverflow.com/a/48043781/1502448
I solved it by following this:
Add a file named
webpack.config.jsin.storybookas below:should be:
Hi @thehappydinoa, Create React App does not support Less, which is why the Create React App preset doesn’t.
You’ll definitely need to modify the Webpack config to make this work - which it looks like you have done 😃
Just a quick update. The only way I could get it working with
v5.3.19is with this:and
(Ignore my addons if you don’t have them set up)
This works as of today. Borrowed from @bkeating’s post and Storybook’s docs at: https://storybook.js.org/configurations/custom-webpack-config