@storybook/react-webpack5
Version:
Storybook for React and Webpack: Develop, document, and test UI components in isolation
43 lines (39 loc) • 1.77 kB
JavaScript
import CJS_COMPAT_NODE_URL_n72k3ln19s from 'node:url';
import CJS_COMPAT_NODE_PATH_n72k3ln19s from 'node:path';
import CJS_COMPAT_NODE_MODULE_n72k3ln19s from "node:module";
var __filename = CJS_COMPAT_NODE_URL_n72k3ln19s.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_n72k3ln19s.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_n72k3ln19s.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
// src/preset.ts
import { fileURLToPath } from "node:url";
import { WebpackDefinePlugin } from "@storybook/builder-webpack5";
var addons = [
fileURLToPath(import.meta.resolve("@storybook/preset-react-webpack"))
], core = async (config, options) => {
let framework = await options.presets.apply("framework");
return {
...config,
builder: {
name: fileURLToPath(import.meta.resolve("@storybook/builder-webpack5")),
options: typeof framework == "string" ? {} : framework.options.builder || {}
},
renderer: fileURLToPath(import.meta.resolve("@storybook/react/preset"))
};
}, webpack = async (config, options) => (config.resolve = config.resolve || {}, config.resolve.alias = {
...config.resolve?.alias,
"@storybook/react": fileURLToPath(import.meta.resolve("@storybook/react"))
}, options.features?.developmentModeForBuild && (config.plugins = [
// @ts-expect-error Ignore this error, because in the `webpack` preset the user actually hasn't defined a config yet.
...config.plugins,
new WebpackDefinePlugin({
NODE_ENV: JSON.stringify("development")
})
]), config);
export {
addons,
core,
webpack
};