@storybook/preset-typescript
TypeScript preset for Storybook
Last updated 6 months ago by shilman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @storybook/preset-typescript 
SYNC missed versions from official npm registry.

Storybook TypeScript preset

One-line TypeScript configuration for Storybook.

Installation

First, install this preset to your project.

npm install -D @storybook/preset-typescript ts-loader fork-ts-checker-webpack-plugin # or yarn

Once installed, add this preset to the appropriate file:

  • ./.storybook/main.js (for Storybook 5.3.0 and newer)

    module.exports = {
      addons: ['@storybook/preset-typescript'],
    };
    
  • ./.storybook/presets.js (for all Storybook versions)

    module.exports = ['@storybook/preset-typescript'];
    

Advanced usage

You can also pass extra configuration options to configure the preset. For example:

// ./storybook/main.js
const path = require('path');

module.exports = {
  addons: [
    {
      name: '@storybook/preset-typescript',
      options: {
        tsLoaderOptions: {
          configFile: path.resolve(__dirname, './tsconfig.json'),
        },
        forkTsCheckerWebpackPluginOptions: {
          colors: false, // disables built-in colors in logger messages
        },
        include: [path.resolve(__dirname, '../src')],
        transpileManager: true,
      },
    },
  ],
};

All available options are described in the Options section below.

Options

forkTsCheckerWebpackPluginOptions

Type: Object

Default value
undefined;

fork-ts-checker-webpack-plugin options. transpileOnly flag needs to be set to true in tsLoaderOptions to be able to set options for this webpack plugin.

include

Type: Rule condition

Default value
undefined;

include rule for /\.tsx?$/.

transpileManager

Type: Boolean

Default value
false;

Toggles TypeScript transpilation on manager side.

Current Tags

  • 3.0.0                                ...           latest (6 months ago)
  • 3.0.0-alpha.1                                ...           next (6 months ago)

10 Versions

  • 3.0.0                                ...           6 months ago
  • 3.0.0-alpha.1                                ...           6 months ago
  • 3.0.0-alpha.0                                ...           6 months ago
  • 2.1.0                                ...           6 months ago
  • 2.0.0                                ...           6 months ago
  • 1.2.2                                ...           6 months ago
  • 1.2.1                                ...           6 months ago
  • 1.2.0                                ...           9 months ago
  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           a year ago

Copyright 2014 - 2016 © taobao.org |