Open D3strukt0r opened 1 year ago
I would suspect it has something to do with specifying base: "/storybook/"
.
@JorisAerts i commented out that line, and still get the same error. Also i do still need it, since it will be accessible from myurl.com/storybook/index.html.
I can even comment out the entire viteFinal function, and still get the error.
My app (inside container) is at /app and all the storybook output must go in /app/public/storybook whereas /app/public is the public root, which is why i said i need the base set to /storybook
I have figured out so far that it was symfonyPlugin
(Source code) which caused the issue. If I exclude it in viteFinal, it goes through.
import {defineConfig} from 'vite';
import symfonyPlugin from 'vite-plugin-symfony';
export default defineConfig(({command}) => ({
plugins: [
symfonyPlugin({
viteDevServerHostname: 'localhost',
}),
],
}));
import {mergeConfig} from 'vite';
import symfonyPlugin from 'vite-plugin-symfony';
const config = {
async viteFinal(config, options) {
// While "rendering chunks", Vite will error out with "Entry points must be inside Vite root directory"
if (options.configType === 'PRODUCTION') {
for (let i = 0; i < config.plugins.length; i++) {
if (config.plugins[i].name === symfonyPlugin.name) {
config.plugins.splice(i, 1);
}
}
}
return mergeConfig(config, {});
},
};
export default config;
I don't what causes this, going through the source code, would be too much for my current knowledge.
Version 6.3.0+ needs adjustments to this workaround for anyone looking help in here. The symfony plugin exports 2 plugins now, so we just need to extract the name of the one we need which is "symfony-entrypoints".
import type { StorybookConfig } from '@storybook/react-vite';
import { mergeConfig } from 'vite';
import symfonyPlugin from 'vite-plugin-symfony';
const config: StorybookConfig = {
[...]
async viteFinal(config, options) {
// While "rendering chunks", Vite will error out with "Entry points must be inside Vite root directory"
if (options.configType === 'PRODUCTION' && config.plugins) {
for (let i = 0; i < config.plugins.length; i++) {
const pluginOrArrayOf = config.plugins[i];
if (Array.isArray(pluginOrArrayOf)) {
for (let j = 0; j < pluginOrArrayOf.length; j++) {
// @ts-ignore TODO: Name exists, fix type?
if (pluginOrArrayOf[j]?.name === symfonyPlugin()[0].name) {
config.plugins.splice(i, 1);
}
}
}
}
}
return mergeConfig(config, {
[...]
});
},
};
Nothing to be taken care of by Storybook team, should be handled by the SymfonyPlugin creator
Describe the bug
At work I have tried to upgrade to Storybook 7. Altough I was able to fix the HMR issue that the storybook-server-channel url is fixed to localhost with a patch, I still am unable to build at all.
I am using vite with the following configuration for my application
and here is my
.storybook/main.ts
All my stories are in
assets/stories/*
. I moved them fromsrc/
where the init script put them.The full output of the build:
I also had a console log for the
config
param passed toviteFinal
which looked like thisI don't know if i have misconfigured something or whether there is actually an issue, which is why I'm here.
To Reproduce
Can't quite explain simply ran
npx sb@next init --builder=vite
and added my custom configSystem
Additional context
No response