@storybook/react-native-web-vite
Version:
Storybook for React Native Web and Vite: Develop, document, and test UI components in isolation
59 lines (55 loc) • 2.24 kB
JavaScript
import CJS_COMPAT_NODE_URL_1z0h71rf2hv from 'node:url';
import CJS_COMPAT_NODE_PATH_1z0h71rf2hv from 'node:path';
import CJS_COMPAT_NODE_MODULE_1z0h71rf2hv from "node:module";
var __filename = CJS_COMPAT_NODE_URL_1z0h71rf2hv.fileURLToPath(import.meta.url);
var __dirname = CJS_COMPAT_NODE_PATH_1z0h71rf2hv.dirname(__filename);
var require = CJS_COMPAT_NODE_MODULE_1z0h71rf2hv.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
__name
} from "./_node-chunks/chunk-6O7V55NE.js";
// src/preset.ts
import { viteFinal as reactViteFinal } from "@storybook/react-vite/preset";
import { rnw } from "vite-plugin-rnw";
import tsconfigPaths from "vite-tsconfig-paths";
var getExcludeOptions = /* @__PURE__ */ __name((modulesToTranspile) => {
const defaultModulesToTranspile = ["react-native", "@react-native", "expo", "@expo"];
const uniqueModulesToTranspile = Array.from(
/* @__PURE__ */ new Set([...modulesToTranspile, ...defaultModulesToTranspile])
);
if (modulesToTranspile.length) {
return { exclude: new RegExp(`/node_modules/(?!${uniqueModulesToTranspile.join("|")})`) };
}
return {};
}, "getExcludeOptions");
var viteFinal = /* @__PURE__ */ __name(async (config, options) => {
const { mergeConfig } = await import("vite");
const { pluginReactOptions = {}, modulesToTranspile = [] } = await options.presets.apply("frameworkOptions");
const { plugins = [], ...reactConfigWithoutPlugins } = await reactViteFinal(config, options);
return mergeConfig(reactConfigWithoutPlugins, {
plugins: [
tsconfigPaths(),
rnw({
...getExcludeOptions(modulesToTranspile),
...pluginReactOptions,
jsxRuntime: pluginReactOptions.jsxRuntime || "automatic",
babel: {
babelrc: false,
configFile: false,
...pluginReactOptions.babel
}
}),
...plugins
]
});
}, "viteFinal");
var core = {
builder: import.meta.resolve("@storybook/builder-vite"),
renderer: import.meta.resolve("@storybook/react/preset")
};
export {
core,
viteFinal
};