sourcegraph/client/storybook
2023-02-02 19:14:25 -08:00
..
assets/img web: update branding colors and Sourcegraph logo images (#23751) 2021-08-13 18:58:09 +08:00
src web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
.eslintignore web: moved Storybook config into a new package (#19569) 2021-04-08 17:16:26 +08:00
.eslintrc.js web: moved Storybook config into a new package (#19569) 2021-04-08 17:16:26 +08:00
babel.config.js web: moved Storybook config into a new package (#19569) 2021-04-08 17:16:26 +08:00
BUILD.bazel build: add sass bazel build (#47139) 2023-02-02 19:14:25 -08:00
globals.d.ts Rely on MonacoWebpackPlugin for worker config (#25886) 2021-10-12 14:01:36 +02:00
jest.config.js web: moved Storybook config into a new package (#19569) 2021-04-08 17:16:26 +08:00
package.json web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
README.md web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
tsconfig.json web: sync TS project refenreces (#46407) 2023-01-16 18:55:10 -08:00

Storybook configuration

Check out the Storybook section in the Developing the Sourcegraph web app docs.

Usage

Storybook configuration is set up as a pnpm workspace symlink.

Important commands are exposed via root package.json:

pnpm storybook
pnpm storybook:build

Environment variables

# Load only a subset of stories to boost build performance.
STORIES_GLOB='client/web/src/**/*.story.tsx' pnpm start

# Enable `webpack-bundle-analyzer` plugin.
WEBPACK_BUNDLE_ANALYZER=true pnpm start

# Enable `speed-measure-webpack-plugin` plugin.
WEBPACK_SPEED_ANALYZER=true pnpm start

# Enable `webpack-dll-plugin`.
WEBPACK_DLL_PLUGIN=true pnpm start

# Enabled `webpack-progress-plugin`.
WEBPACK_PROGRESS_PLUGIN=true pnpm start

# Enable minification and Webpack config production mode.
MINIFY=true pnpm build

DLL Plugin

The DLL Plugin is used to move most third-party dependencies into a separate pre-built bundle to speed up development build. To start Storybook development server with DLL Plugin enabled run: pnpm start:dll from the Storybook workspace or pnpm storybook:dll from the root folder.

How pnpm start:dll works

  1. DllReferencePlugin is enabled in the Storybook configuration via the WEBPACK_DLL_PLUGIN environment variable.
  2. If the DLL manifest is not available at ./assets/dll-bundle/dll-plugin.manifest.json, the pnpm build:dll-bundle command is executed to create a DLL bundle.
  3. The list of third-party dependencies from Webpack stats is required to create a DLL bundle. If Webpack stats are not available at ./storybook-static/preview-stats.json, the pnpm build:webpack-stats command is executed to create them.
  4. Webpack stats are generated from storybook-start --webpack-stats-json command.
  5. DLL bundle is built using Webpack config ./src/webpack.config.dll.ts.
  6. DllReferencePlugin is initialized using just created DLL manifest.
  7. Storybook development server starts 🎉.

If DLL bundle and Webpack stats are in place, all intermediate steps are skipped straight to the start of Storybook development server.