Skip to content
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

[Bug]: previewMainTemplate Option Ignored, Default Template Used Instead #28300

Open
Shadowrunner11 opened this issue Jun 20, 2024 · 0 comments

Comments

@Shadowrunner11
Copy link

Shadowrunner11 commented Jun 20, 2024

Describe the bug

In the Storybook configuration, there is an option called previewMainTemplate which is intended to allow users to override the default template.ejs used by the Storybook build-manager when creating the main index.html of the standalone application.

However, when a custom path to an .ejs template is provided for the previewMainTemplate option and either storybook build or storybook dev is run, the custom template is not utilized as expected. Instead, the build process continues to use the default template.ejs , ignoring the previewMainTemplate configuration.

Reproduction link

https://stackblitz.com/edit/github-sbmzvp?file=.storybook%2FcustomIndex.ejs&view=editor

Reproduction steps

  1. Go to the link above
  2. Wait for the execution of yarn build-storybook or execute it manually in the integrated terminal
  3. Open the generated storybook-static/index.html a
  4. Compare the mentioned file with .storybook/customIndex.ejs template if the correct changes are being applied from the template to the static html file.

System

Storybook Environment Info:

  System:
    OS: macOS 14.2
    CPU: (12) arm64 Apple M2 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v18.19.1/bin/npm
    pnpm: 8.9.0 - ~/Library/pnpm/pnpm <----- active
  Browsers:
    Chrome: 122.0.6261.129
    Safari: 17.2
  npmPackages:
    @storybook/addon-essentials: ^8.1.10 => 8.1.10 
    @storybook/addon-interactions: ^8.1.10 => 8.1.10 
    @storybook/addon-links: ^8.1.10 => 8.1.10 
    @storybook/addon-onboarding: ^8.1.10 => 8.1.10 
    @storybook/blocks: ^8.1.10 => 8.1.10 
    @storybook/react: ^8.1.10 => 8.1.10 
    @storybook/react-vite: ^8.1.10 => 8.1.10 
    @storybook/test: ^8.1.10 => 8.1.10 
    eslint-plugin-storybook: ^0.8.0 => 0.8.0 
    storybook: ^8.1.10 => 8.1.10

Additional context

This is happening because in this line

const template = readTemplate('template.ejs');

the value of the the path to the template is being harcoded and resolved to the template.ejs of the library instead of resolving from the options.

In the meantime I provided a turn around while I work in the solution
#28301

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant