-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Does not support less #691
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
Comments
Hi @Peakdrum Check the storybook documentation about custom webpack config. Hope this help! |
@Peakdrum you can use this:
|
This was very helpful. Being that my project is via Install webpack loaders: yarn add style-loader css-loader less-loader Create a new, local webpack config at const path = require('path');
// load the default config generator.
let genDefaultConfig = require('@kadira/storybook/dist/server/config/defaults/webpack.config.js');
module.exports = function(config, env) {
let extendedDefaultConfig = genDefaultConfig(config, env);
// Make whatever fine-grained changes you need
extendedDefaultConfig.module.loaders.push({
test: /\.less$/,
loaders: ['style-loader', 'css-loader', 'less-loader'],
include: path.resolve(__dirname, '../src/')
});
return extendedDefaultConfig;
}; |
Cool thanks |
may be webpack not match less file . path.resolve(__dirname, '../src/'),,,you can remove this and then try again |
This works as of today. Borrowed from @bkeating's post and Storybook's docs at: https://storybook.js.org/configurations/custom-webpack-config
|
@leojh is that the only thing you had to change to make it work? I'm still having trouble |
That was it and our setup is quite complex. Make sure you're on the latest version of storybook. |
Which dependencies did you install to make this work? |
make sure you have these two I have these right now:
|
Hi,
this is an example error. Their are more errors like this. Have anyone an idea how to solve this? |
I also needed antd to work with storybook and found I needed javascriptEnabled option also:
|
I'm seeing a less issue :(
It's still failing, even after following the docs and replacing for 'less' |
Hello @tcjcodes! // .storybook/manager.js
import "./index.less"; // .storybook/main.js
const path = require("path")
module.exports = {
webpackFinal: async config => {
config.module.rules.push({
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { modules: false } },
{ loader: 'less-loader', options: { javascriptEnabled: true }}
]
})
return config
}
} I was confused a bit as the same approach worked if I import // .storybook/config.js
import "./index.less"; |
// .storybook/manager.js
import "./index.less"; should be: // .storybook/preview.js
import "./index.less"; |
Just a quick update. The only way I could get it working with // .storybook/main.js
const path = require('path');
module.exports = {
stories: ['../src/**/*.stories.js'],
addons: [
{
name: '@storybook/preset-create-react-app',
options: {
craOverrides: {
fileLoaderExcludes: ['less'],
},
},
},
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-knobs/register',
'@storybook/addon-storysource',
],
webpackFinal: async (config) => {
config.module.rules.push({
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { modules: false } },
{
loader: 'less-loader',
options: { lessOptions: { javascriptEnabled: true } },
},
],
});
return config;
},
}; and // .storybook/preview.js
import React from 'react';
import { addDecorator } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import '../src/styles/global.less';
addDecorator(withKnobs) (Ignore my addons if you don't have them set up) |
@thehappydinoa what version of |
@shilman Here is my storybook versions: {
"@storybook/addon-actions": "^5.3.19",
"@storybook/addon-knobs": "^5.3.19",
"@storybook/addon-links": "^5.3.19",
"@storybook/addon-viewport": "^5.3.19",
"@storybook/addons": "^5.3.19",
"@storybook/preset-create-react-app": "^3.1.4",
"@storybook/react": "^5.3.19",
"@storybook/theming": "^5.3.19",
} |
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 :) |
I solved it by following this:
Add a file named
|
if dont work, you can add another piece of code
|
it not work |
I am trying to use storybook with antd but in antd it is using less so I have this error:
Can anyone help me adding less to storybook ? Thanks a lot
The text was updated successfully, but these errors were encountered: