Builder implemented with webpack5 and webpack5-compatible loaders/plugins/config, used by @storybook/core-server to build the manager UI
—
Support for using prebuilt manager bundles when the Storybook configuration meets certain criteria, providing optimal performance for standard configurations.
Determines if a prebuilt manager can be used based on configuration analysis.
/**
* Get path to prebuilt manager or false if not available
* @param options - Storybook configuration options
* @returns Promise resolving to prebuilt directory path or false
*/
function getPrebuiltDir(options: Options): Promise<string | false>;
interface Options {
/** Path to Storybook configuration directory */
configDir: string;
/** Smoke test mode flag - disables prebuilt manager */
smokeTest?: boolean;
/** Manager cache flag - must be enabled for prebuilt manager */
managerCache?: boolean;
}Usage Examples:
import { getPrebuiltDir } from "@storybook/manager-webpack5/utils/prebuilt-manager";
const prebuiltPath = await getPrebuiltDir({
configDir: '.storybook',
managerCache: true,
smokeTest: false,
});
if (prebuiltPath) {
console.log('Using prebuilt manager from:', prebuiltPath);
// Serve static files from prebuilt directory
} else {
console.log('Building manager from source');
// Proceed with webpack build
}The prebuilt manager can only be used when ALL of the following conditions are met:
managerCache !== false)smokeTest !== true).storybook/manager.js file)managerWebpack in main config)managerBabel in main config)refs in config and no auto-discovered refs)features configuration)Standard addons that are automatically installed with sb init and compatible with prebuilt manager.
/**
* List of default addons installed with sb init
*/
const DEFAULT_ADDONS: string[] = [
'@storybook/addon-links',
'@storybook/addon-essentials'
];Usage Examples:
import { DEFAULT_ADDONS } from "@storybook/manager-webpack5/utils/prebuilt-manager";
// Check if configuration only uses default addons
const configAddons = ['@storybook/addon-links', '@storybook/addon-essentials'];
const onlyDefaultAddons = configAddons.every(addon => DEFAULT_ADDONS.includes(addon));Addons that don't affect the manager build and can be safely ignored when determining prebuilt manager eligibility.
/**
* Addons that don't affect manager build and can be ignored
*/
const IGNORED_ADDONS: string[] = [
'@storybook/preset-create-react-app',
'@storybook/preset-scss',
'@storybook/preset-typescript',
'@storybook/addon-links',
'@storybook/addon-essentials'
];Usage Examples:
import { IGNORED_ADDONS } from "@storybook/manager-webpack5/utils/prebuilt-manager";
// Filter out addons that don't affect manager
const managerAffectingAddons = allAddons.filter(addon =>
!IGNORED_ADDONS.includes(addon)
);
if (managerAffectingAddons.length === 0) {
console.log('No manager-affecting addons, prebuilt manager eligible');
}The prebuilt manager system analyzes the Storybook configuration to determine compatibility:
Examines the main configuration file for:
interface MainConfig {
/** Array of addon names/paths */
addons?: string[];
/** Composition references */
refs?: Record<string, any>;
/** Custom manager webpack configuration */
managerWebpack?: Function;
/** Custom manager babel configuration */
managerBabel?: Function;
/** Feature flags */
features?: Record<string, any>;
}Checks for automatic composition references by:
storybook.url configurationExample of auto-discovered ref:
{
"name": "@company/design-system",
"storybook": {
"url": "https://design-system.company.com"
}
}Using prebuilt manager provides significant performance improvements:
When prebuilt manager cannot be used, the system gracefully falls back to:
To debug why prebuilt manager isn't being used:
import { getPrebuiltDir, DEFAULT_ADDONS, IGNORED_ADDONS } from "@storybook/manager-webpack5/utils/prebuilt-manager";
import { getAutoRefs } from "@storybook/manager-webpack5/manager-config";
async function debugPrebuiltEligibility(options: Options) {
const prebuiltDir = await getPrebuiltDir(options);
if (!prebuiltDir) {
// Check each condition individually
console.log('Prebuilt manager not available. Checking conditions:');
// Check for auto refs
const autoRefs = await getAutoRefs(options);
console.log('Auto refs found:', autoRefs.length);
// Check other conditions...
}
}Install with Tessl CLI
npx tessl i tessl/npm-storybook--manager-webpack5