Storybook: How to add a <script> tag?

Created on 4 May 2016  路  5Comments  路  Source: storybookjs/storybook

react-prism recommends to add a script tag directly in the HTML:

<script src="path/to/your/prism.js" ></script>

Is there a way to do this?

question / support

Most helpful comment

updating the answer: add a preview-head.html to the folder .storybook.

All 5 comments

Yes, there is, but I don't think there's any docs on it yet. See #77.

Basically, create a head.html in your .storybook. That will get included.

_Note: This will add it to <head>_

Thanks!

updating the answer: add a preview-head.html to the folder .storybook.

There doesn't seem to be a way to do this for local dependencies. What's the best way to get these into stories & the build output?

<script nomodule src="/dist/my-custom-script.js"></script>

Error: ENOENT: no such file or directory, stat '.../my-project/node_modules/@storybook/core/dist/public/dist/my-custom-script.js'

You can find the doc on the official website at this address: https://storybook.js.org/docs/configurations/add-custom-head-tags/

Was this page helpful?
0 / 5 - 0 ratings