You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.
import{configure}from'@storybook/vue'// automatically import all files ending in *.stories.jsconstreq=require.context('../src/stories',true,/.stories.ts$/);functionloadStories(){req.keys().forEach((filename)=>req(filename));}configure(loadStories,module)
./.storybook/webpack.conf.js:
constForkTsCheckerWebpackPlugin=require('fork-ts-checker-webpack-plugin');constgenDefaultConfig=require('@storybook/vue/dist/server/config/defaults/webpack.config.js');module.exports=(storybookBaseConfig,configType)=>{constconfig=genDefaultConfig(storybookBaseConfig,configType);config.resolve.extensions.push('.ts','.tsx','.vue','.css','.less','.scss','.sass','.html')config.module.rules.push({test: /\.ts$/,exclude: /node_modules/,use: [{loader: 'ts-loader',options: {appendTsSuffixTo: [/\.vue$/],transpileOnly: true// used with ForkTsCheckerWebpackPlugin},}],})config.plugins.push(newForkTsCheckerWebpackPlugin())returnconfig;};
The text was updated successfully, but these errors were encountered:
the -c .storybook is probably redundant as that's the default
c) getstorybook should create a ./.storybook/ directory,
if the above don't install, then add manually.
edit these files in ./.storybook/ as above (or create if they don't exist):
./.storybook/config.js and
./.storybook/webpack.conf.js
you'll also need the plugin: 'ForkTsCheckerWebpackPlugin' configured as above, dramatically reduces compile time (a factor of 10x in my case).
kick off the storybook server: npm run storybook
Optionally install Storybook 'addons', most work for Vue.
HOWEVER: Storybook remounts the component everytime you use the interaction addon (called 'knobs'), so I find it better to create a Vue component for each 'story', and let that vue component interact with your component-under-test.
The other thing to be aware of is that Storybook is written in React, with the Vue components in separate iFrames. As such, Vue Devtools doesn't see the components (but it does see Vuex stores and events!).
Dave
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
These work, for Vue + Typescript + Webpack:
The text was updated successfully, but these errors were encountered: