CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-storybook--manager-webpack5

Builder implemented with webpack5 and webpack5-compatible loaders/plugins/config, used by @storybook/core-server to build the manager UI

Pending
Overview
Eval results
Files

webpack-config.mddocs/

Webpack Configuration

Webpack5 configuration generation with manager-specific settings, plugin configuration, entry point management, and Storybook composition support.

Capabilities

Manager Webpack Configuration

Generates the complete webpack configuration for building the Storybook manager UI.

/**
 * Generate webpack configuration for manager build
 * @param options - Storybook configuration options
 * @returns Promise resolving to complete webpack Configuration
 */
function getManagerWebpackConfig(options: Options): Promise<Configuration>;

interface Options {
  /** Path to Storybook configuration directory */
  configDir: string;
  /** Output directory for built files */
  outputDir?: string;
  /** Preset collection for configuration */
  presets: PresetCollection;
  /** Cache provider for build optimization */
  cache?: CacheProvider;
  /** Enable manager caching */
  managerCache?: boolean;
  /** Smoke test mode flag */
  smokeTest?: boolean;
  /** Configuration type (DEVELOPMENT|PRODUCTION) */
  configType?: string;
  /** Documentation mode flag */
  docsMode?: boolean;
  /** Preview URL for manager */
  previewUrl?: string;
  /** Version check configuration */
  versionCheck?: any;
  /** Release notes data */
  releaseNotesData?: any;
  /** Feature flags */
  features?: Record<string, any>;
  /** Server channel URL */
  serverChannelUrl?: string;
}

Usage Examples:

import { getManagerWebpackConfig } from "@storybook/manager-webpack5/manager-config";

const config = await getManagerWebpackConfig({
  configDir: '.storybook',
  outputDir: './storybook-static',
  presets: presetCollection,
  configType: 'PRODUCTION',
  cache: cacheProvider,
  managerCache: true,
});

console.log('Entry points:', config.entry);
console.log('Output path:', config.output?.path);

Auto-Discovery of Composition Refs

Automatically discovers Storybook composition references from package dependencies.

/**
 * Auto-discover Storybook composition refs from dependencies
 * @param options - Storybook configuration options
 * @param disabledRefs - Array of ref IDs to exclude from discovery
 * @returns Promise resolving to array of discovered refs
 */
function getAutoRefs(options: Options, disabledRefs?: string[]): Promise<Ref[]>;

interface Ref {
  /** Unique identifier for the ref */
  id: string;
  /** URL where the Storybook is hosted */
  url: string;
  /** Display title for the ref */
  title: string;
  /** Version of the referenced Storybook */
  version?: string;
  /** Type indicating server accessibility */
  type?: 'server-checked' | 'unknown';
}

Usage Examples:

import { getAutoRefs } from "@storybook/manager-webpack5/manager-config";

// Discover all available refs
const allRefs = await getAutoRefs(options);

// Discover refs excluding specific ones
const filteredRefs = await getAutoRefs(options, [
  '@company/design-system',
  '@company/legacy-components'
]);

console.log('Available composition refs:', allRefs);

Manager Webpack Preset

Core webpack configuration preset with plugins, loaders, and optimization settings.

/**
 * Configure webpack for manager build with plugins and loaders
 * @param config - Base webpack configuration (usually empty)
 * @param options - Extended options with manager-specific settings
 * @returns Promise resolving to complete webpack Configuration
 */
function managerWebpack(
  config: Configuration,
  options: Options & ManagerWebpackOptions
): Promise<Configuration>;

interface ManagerWebpackOptions {
  /** Webpack entry points */
  entries: string[];
  /** Composition refs configuration */
  refs?: Record<string, Ref>;
  /** Modern build flag */
  modern?: boolean;
}

Usage Examples:

import { managerWebpack } from "@storybook/manager-webpack5/presets/manager-preset";

const finalConfig = await managerWebpack({}, {
  configDir: '.storybook',
  outputDir: './storybook-static',
  configType: 'PRODUCTION',
  entries: ['./src/manager.ts'],
  refs: discoveredRefs,
  modern: true,
  presets: presetCollection,
});

Manager Entry Points

Determines the entry points for the manager bundle including addons and configuration.

/**
 * Determine entry points for manager bundle
 * @param installedAddons - Array of installed addon names
 * @param options - Entry point configuration options
 * @returns Promise resolving to array of entry point paths
 */
function managerEntries(
  installedAddons: string[],
  options: ManagerEntryOptions
): Promise<string[]>;

interface ManagerEntryOptions {
  /** Main manager entry point */
  managerEntry?: string;
  /** Path to Storybook configuration directory */
  configDir: string;
  /** Enable modern build mode */
  modern?: boolean;
}

Usage Examples:

import { managerEntries } from "@storybook/manager-webpack5/presets/manager-preset";

const entries = await managerEntries(
  ['@storybook/addon-actions', '@storybook/addon-controls'],
  {
    configDir: '.storybook',
    managerEntry: '@storybook/core-client/dist/esm/manager',
    modern: false,
  }
);

console.log('Manager entry points:', entries);

Babel Loader Configuration

Creates babel-loader webpack rule configuration for manager-specific transpilation.

/**
 * Create babel-loader webpack rule for manager
 * @returns Webpack rule configuration for babel-loader
 */
function babelLoader(): RuleSetRule;

interface RuleSetRule {
  test: RegExp;
  use: LoaderConfig[];
  include: string[];
  exclude: RegExp[];
}

interface LoaderConfig {
  loader: string;
  options: BabelLoaderOptions;
}

interface BabelLoaderOptions {
  sourceType: 'unambiguous';
  presets: string[];
  plugins: string[];
  babelrc: false;
  configFile: false;
}

Usage Examples:

import { babelLoader } from "@storybook/manager-webpack5/presets/babel-loader-manager";

const babelRule = babelLoader();

const webpackConfig = {
  module: {
    rules: [
      babelRule,
      // ... other rules
    ],
  },
};

Configuration Features

The webpack configuration includes:

  • Modern JavaScript/TypeScript Processing: Babel loader with React preset and template literal transformation
  • CSS Support: Style-loader and css-loader for CSS processing
  • Asset Handling: File loader for images, fonts, and media files with content hashing
  • HTML Generation: HtmlWebpackPlugin for manager HTML with template injection
  • Virtual Modules: Support for dynamically generated modules (refs configuration)
  • Development Server: Webpack dev middleware integration for hot reloading
  • Production Optimization: Code splitting, minification, and tree shaking
  • Caching: Persistent caching for improved build performance

Install with Tessl CLI

npx tessl i tessl/npm-storybook--manager-webpack5

docs

builder-functions.md

caching.md

index.md

prebuilt-manager.md

webpack-config.md

tile.json