7.2.5 • Published 10 months ago

@junk-temporary-prototypes/source-loader v7.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Storybook source-loader is a webpack loader that annotates Storybook story files with their source code. It powers the storysource and docs addons.

Options

The loader can be customized with the following options:

parser

The parser that will be parsing your code to AST (based on prettier)

Allowed values:

  • javascript - default
  • typescript
  • flow

Be sure to update the regex test for the webpack rule if utilizing Typescript files.

Usage:

module.exports = function ({ config }) {
  config.module.rules.push({
    test: /\.stories\.tsx?$/,
    use: [
      {
        loader: require.resolve('@storybook/source-loader'),
        options: { parser: 'typescript' },
      },
    ],
    enforce: 'pre',
  });

  return config;
};

prettierConfig

The prettier configuration that will be used to format the story source in the addon panel.

Defaults:

{
  printWidth: 100,
  tabWidth: 2,
  bracketSpacing: true,
  trailingComma: 'es5',
  singleQuote: true,
}

Usage:

module.exports = function ({ config }) {
  config.module.rules.push({
    test: /\.stories\.jsx?$/,
    use: [
      {
        loader: require.resolve('@storybook/source-loader'),
        options: {
          prettierConfig: {
            printWidth: 100,
            singleQuote: false,
          },
        },
      },
    ],
    enforce: 'pre',
  });

  return config;
};

uglyCommentsRegex

The array of regex that is used to remove "ugly" comments.

Defaults:

[/^eslint-.*/, /^global.*/];

Usage:

module.exports = function ({ config }) {
  config.module.rules.push({
    test: /\.stories\.jsx?$/,
    use: [
      {
        loader: require.resolve('@storybook/source-loader'),
        options: {
          uglyCommentsRegex: [/^eslint-.*/, /^global.*/],
        },
      },
    ],
    enforce: 'pre',
  });

  return config;
};

injectDecorator

Tell storysource whether you need inject decorator. If false, you need to add the decorator by yourself;

Defaults: true

Usage:

module.exports = function ({ config }) {
  config.module.rules.push({
    test: /\.stories\.jsx?$/,
    use: [
      {
        loader: require.resolve('@storybook/source-loader'),
        options: { injectDecorator: false },
      },
    ],
    enforce: 'pre',
  });

  return config;
};
7.2.5

11 months ago

7.2.4

11 months ago

7.2.3

11 months ago

7.2.2

11 months ago

7.2.1

11 months ago

7.2.0

11 months ago

7.2.0-alpha.6

11 months ago

7.2.0-alpha.5

11 months ago

7.2.0-alpha.4

11 months ago

7.2.0-alpha.3

11 months ago

7.2.0-alpha.2

11 months ago

7.0.8-alpha.4

11 months ago

7.0.8-alpha.3

12 months ago

7.0.8-alpha.2

12 months ago

7.0.8-alpha.1

12 months ago

7.0.8-alpha.0

12 months ago

7.1.1

1 year ago

7.0.9

1 year ago

7.1.0

1 year ago

7.1.0-beta.2

1 year ago

7.1.0-alpha.1

1 year ago

7.1.0-alpha.0

1 year ago

7.0.8

1 year ago

7.0.7

1 year ago