storybook icon indicating copy to clipboard operation
storybook copied to clipboard

[Bug]: Init fails when using appTemplate or routes config w/ @storybook/sveltekit

Open F1LT3R opened this issue 1 year ago • 0 comments

Describe the bug

When using appTemplate and routes in storybook.config.js, @storybook/sveltekit cannot find files from the storybook directory.

image

However, when using the standard config, everything works as expected.

image

Storybook MUST pick up the route and template configs from story storybook.config.js to be viable for production codebases.

Production code for large organizations tends to have more deeply nested directories and use non-standard configurations to provide separation between server code, web code, service integrations, and so on.

To Reproduce

  1. Create a SvelteKit project with the following config for Svelte and Vite:

    // svelte.config.js
    const config = {
        kit: {
            files: {
                routes: './web/routes',
                appTemplate: './web/app.html'
            }
        }
    };
    
    export default config;
    
    import { sveltekit } from '@sveltejs/kit/vite';
    import { defineConfig, searchForWorkspaceRoot } from 'vite';
    
    export default defineConfig({
    	plugins: [sveltekit()],
    
    	server: {
    		fs: {
    			allow: [searchForWorkspaceRoot(process.cwd())]
    		}
    	}
    });
    
  2. Run npx sb init

    You will then see a message like:

    The request url "/home/user/my-repo/stories/Configure.mdx" is outside of Vite serving allow list.

    image

System

System:
    OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1270P
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 21.2.0 - ~/.nvm/versions/node/v21.2.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v21.2.0/bin/npm <----- active
  npmPackages:
    @storybook/addon-essentials: ^7.6.11 => 7.6.11
    @storybook/addon-interactions: ^7.6.11 => 7.6.11
    @storybook/addon-links: ^7.6.11 => 7.6.11
    @storybook/blocks: ^7.6.11 => 7.6.11
    @storybook/svelte: ^7.6.11 => 7.6.11
    @storybook/sveltekit: ^7.6.11 => 7.6.11
    @storybook/test: ^7.6.11 => 7.6.11
    storybook: ^7.6.11 => 7.6.11

Additional context

No response

F1LT3R avatar Jan 31 '24 14:01 F1LT3R