I started using storybook for my react-typescript project recently and ran into below issues:
I am running storybook locally on localhost.
Below is my main.js with custom webpack configuration :
module.exports = {
stories: ['../src/stories/**/*.stories.[tj]s','../src/stories/**/*.stories.tsx'],
addons: ['@storybook/addon-actions', '@storybook/addon-links'],
webpackFinal: async config => {
config.module.rules.push({
test: /(?<!.*\.test)\.(ts|tsx)$/,
use: [
{
loader: require.resolve('ts-loader'),
}
]
},
{
test: /\.ttf$|\.woff$|\.eot$|\.otf$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: '/static/fonts',
},
},
]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
);
config.resolve.extensions.push('.ts', '.tsx');
return config;
},
};
I don't have a formal answer but perhaps storybook cannot identify by default that bootstrap is being used.
A quick workaround that I'm doing is to add the following line import 'bootstrap/dist/css/bootstrap.css'; on the stories.js files. It allows me to visualize my reactrsap components with their proper styling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With