@storybook/react-webpack5
Version:
Storybook for React and Webpack: Develop, document, and test UI components in isolation
55 lines (51 loc) • 1.96 kB
JavaScript
import CJS_COMPAT_NODE_URL_t3t4obn1m from 'node:url';
import CJS_COMPAT_NODE_PATH_t3t4obn1m from 'node:path';
import CJS_COMPAT_NODE_MODULE_t3t4obn1m from "node:module";
var __filename = CJS_COMPAT_NODE_URL_t3t4obn1m.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_t3t4obn1m.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_t3t4obn1m.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
__name
} from "./_node-chunks/chunk-775COY5G.js";
// src/preset.ts
import { fileURLToPath } from "node:url";
import { WebpackDefinePlugin } from "@storybook/builder-webpack5";
var addons = [
fileURLToPath(import.meta.resolve("@storybook/preset-react-webpack"))
];
var core = /* @__PURE__ */ __name(async (config, options) => {
const 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"))
};
}, "core");
var webpack = /* @__PURE__ */ __name(async (config, options) => {
config.resolve = config.resolve || {};
config.resolve.alias = {
...config.resolve?.alias,
"@storybook/react": fileURLToPath(import.meta.resolve("@storybook/react"))
};
if (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")
})
];
}
return config;
}, "webpack");
export {
addons,
core,
webpack
};