storybook-addon-run-script
This storybook addon can be helpful to run a script inside your preview window by appending a script tag with your script content.
Addon Support Table
React | React Native | Vue | Angular | Polymer | Mithril | HTML | Marko | Svelte | Riot | Ember | Preact |
---|---|---|---|---|---|---|---|---|---|---|---|
+ |
Getting started
First, install the addon.
> npm i storybook-addon-run-script -DOR> yarn add storybook-addon-run-script --dev
Usage
example for HTML with component:
;; ; ; storiesOf'MyComponent', module .addDecoratorwithRunScriptrunScript .add'default',Component;
Tips
You may find it helpful to import a js file as a string to allow you to write JS code with IDE support. You can configure the Webpack config, read more in the docs.
Sample webpack.config.js
config:
module.exports = ;
You may need to install raw-loader
> npm i raw-loader -DOR> yarn add raw-loader --dev
You may then use it as so:
;; ;// The following imported file will be imported as a string; storiesOf'MyComponent', module .addDecoratorwithRunScriptrunScript .add'default',Component;
Roadmap
- Support more libraries
- Add Tests
- Add CI