vite-plugin-react-server
Version:
Vite plugin for React Server Components (RSC)
52 lines (49 loc) • 1.9 kB
JavaScript
/**
* vite-plugin-react-server
* Copyright (c) Nico Brinkkemper
* MIT License
*/
import { Html } from '../html.js';
const DEFAULT_CONFIG = {
FILE_REGEX: /\.(m|c)?(j|t)sx?$/,
CLIENT_ASSETS_DIR: "assets",
MODULE_BASE: "src",
MODULE_BASE_PATH: "",
MODULE_BASE_URL: "",
PAGE: "src/page/page.tsx",
PROPS: "src/page/props.ts",
CLIENT_ENTRY: "src/client.tsx",
SERVER_ENTRY: "src/server.tsx",
PAGE_EXPORT_NAME: "Page",
PROPS_EXPORT_NAME: "props",
HTML_WORKER_PATH: `worker/html/html-worker.${process.env["NODE_ENV"] === "development" ? "development" : "production"}.js`,
RSC_WORKER_PATH: `worker/rsc/rsc-worker.${process.env["NODE_ENV"] === "development" ? "development" : "production"}.js`,
LOADER_PATH: "worker/loader.js",
HTML: Html,
COLLECT_CSS: true,
COLLECT_ASSETS: true,
INLINE_CSS: true,
BUILD: {
pages: () => ["/"],
client: "client",
server: "server",
static: "static",
api: "api",
outDir: "dist",
hash: "hash",
preserveModulesRoot: true
},
AUTO_DISCOVER: {
modulePattern: (n) => DEFAULT_CONFIG.FILE_REGEX.test(n),
pagePattern: (n) => n.toLowerCase().endsWith("/page") || n.toLowerCase() === "page",
propsPattern: (n) => n.toLowerCase().endsWith("/props") || n.toLowerCase() === "props",
clientComponents: (n) => n.toLowerCase().endsWith(".client") || n.toLowerCase() === "client",
serverFunctions: (n) => n.toLowerCase().endsWith(".server") || n.toLowerCase() === "server",
cssPattern: (n) => n.toLowerCase().endsWith(".css"),
cssModulePattern: (n) => n.toLowerCase().endsWith(".css.js"),
vendorPattern: (n) => n.toLowerCase().startsWith("node_modules") || n.toLowerCase().startsWith("_virtual"),
htmlPattern: (n) => n.toLowerCase().endsWith(".html"),
jsonPattern: (n) => n.toLowerCase().endsWith(".json")
}};
export { DEFAULT_CONFIG };
//# sourceMappingURL=defaults.js.map