Skip to content

Commit

Permalink
Reused Storybook's Options core type and applied fix to vue3 framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschungelabenteuer committed Mar 16, 2021
1 parent 193cf98 commit 797c605
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
16 changes: 3 additions & 13 deletions addons/docs/src/frameworks/vue/preset.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
interface Preset {
readonly name: string;
readonly options: any;
}

interface PresetOptions {
readonly presetsList: Preset[];
}
import type { Options } from '@storybook/core-common';

export function webpackFinal(
webpackConfig: any = {},
options: PresetOptions = { presetsList: [] }
) {
export function webpackFinal(webpackConfig: any = {}, options: Options) {
let vueDocgenOptions = {};

options.presetsList.forEach((preset) => {
options.presetsList?.forEach((preset) => {
if (preset.name.includes('addon-docs') && preset.options.vueDocgenOptions) {
const appendableOptions = preset.options.vueDocgenOptions;
vueDocgenOptions = {
Expand Down
18 changes: 16 additions & 2 deletions addons/docs/src/frameworks/vue3/preset.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
export function webpackFinal(webpackConfig: any = {}, options: any = {}) {
import type { Options } from '@storybook/core-common';

export function webpackFinal(webpackConfig: any = {}, options: Options) {
let vueDocgenOptions = {};

options.presetsList?.forEach((preset) => {
if (preset.name.includes('addon-docs') && preset.options.vueDocgenOptions) {
const appendableOptions = preset.options.vueDocgenOptions;
vueDocgenOptions = {
...vueDocgenOptions,
...appendableOptions,
};
}
});

webpackConfig.module.rules.push({
test: /\.vue$/,
loader: require.resolve('vue-docgen-loader', { paths: [require.resolve('@storybook/vue3')] }),
enforce: 'post',
options: {
docgenOptions: {
alias: webpackConfig.resolve.alias,
...options.vueDocgenOptions,
...vueDocgenOptions,
},
},
});
Expand Down

0 comments on commit 797c605

Please sign in to comment.