I moved our storybook to vite-builder. My main.cjs now looks like this:
const viteTsconfig = require('vite-tsconfig-paths');
const tsconfigPaths = viteTsconfig.default;
const { mergeConfig } = require('vite');
const config = {
stories: ['../stories/**/*.stories.@(js|jsx|ts|tsx)'],
/** Expose public folder to storybook as static */
staticDirs: ['../public', '../public-assets'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
// '@storybook/addon-interactions',
{
name: '@storybook/addon-postcss',
options: {
postcssLoaderOptions: {
implementation: require('postcss'),
},
},
},
],
framework: '@storybook/react',
core: {
builder: '@storybook/builder-vite',
},
async viteFinal(config) {
return mergeConfig(config, {
plugins: [tsconfigPaths()],
});
},
};
module.exports = config;
And vite.config.ts is using import svgr from 'vite-plugin-svgr'.
When I start storybook, it doesn't crash, but it stays in loading animation forever, and I get the following error in devtools:
Uncaught Error: Cannot find module '/Users/ronny.efronny/projects/frontend/node_modules/@storybook/client-api'
at webpackMissingModule (preview.js:11:1)
I don't understand what this is. I installed @storybook/client-api and added it to addons, and now I get a different error:
The requested module '/public-assets/add.svg?import' does not provide an export named 'ReactComponent'
```.
I don't understand, it seems like completely random errors. In the main App, Vite handles the same SVG files fine. What's going on?