Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

feature suggestion: add storybook #35

@davidm-public

Description

@davidm-public

These work, for Vue + Typescript + Webpack:

  1. ./.storybook/config.js:
import { configure } from '@storybook/vue'

// automatically import all files ending in *.stories.js
const req = require.context('../src/stories', true, /.stories.ts$/);
function loadStories() {
  req.keys().forEach((filename) => req(filename));
}

configure(loadStories, module)
  1. ./.storybook/webpack.conf.js:
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

const genDefaultConfig = require('@storybook/vue/dist/server/config/defaults/webpack.config.js');

module.exports = (storybookBaseConfig, configType) => {
  const config = 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(new ForkTsCheckerWebpackPlugin())

  return config;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions