Skip to content

Commit

Permalink
feat: add storybook addon
Browse files Browse the repository at this point in the history
Fixes #4.
  • Loading branch information
tobiasdiez committed Nov 10, 2022
1 parent b9541ff commit f767fcd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
10 changes: 3 additions & 7 deletions examples/vite/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Inspect from 'vite-plugin-inspect'
import Unplugin from '../../../src/vite'
import { mergeConfig } from 'vite'

export default {
stories: [
Expand All @@ -11,6 +9,7 @@ export default {
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'../../../src/storybook.ts',
],
framework: '@storybook/vue3',
core: {
Expand All @@ -21,11 +20,8 @@ export default {
},
async viteFinal(config, { configType }) {
// Inspect result can be found at subroute '/__inspect', e.g. http://127.0.0.1:6006/__inspect/
config.plugins.unshift(Inspect(), Unplugin())
config.plugins.unshift(Inspect())

return mergeConfig(config, {
// Other customizations: https://github.com/storybookjs/builder-vite#customize-vite-config
// ...
})
return config
},
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
}
},
"files": [
"dist"
"dist",
"preset.js"
],
"scripts": {
"build": "tsup",
Expand Down
1 change: 1 addition & 0 deletions preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/storybook')
8 changes: 8 additions & 0 deletions src/storybook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { StorybookViteConfig } from '@storybook/builder-vite'
import VitePlugin from './vite'

export const viteFinal: StorybookViteConfig['viteFinal'] = (config) => {
config.plugins = config.plugins || []
config.plugins.unshift(VitePlugin({}))
return config
}

0 comments on commit f767fcd

Please sign in to comment.