70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
39 lines
1.6 KiB
TypeScript
39 lines
1.6 KiB
TypeScript
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
import react from "@vitejs/plugin-react";
|
|
import { defineConfig } from "vite";
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
return {
|
|
plugins: [
|
|
react(),
|
|
cloudflare({
|
|
configPath:
|
|
mode === "development" ? "./wrangler.dev.jsonc" : "./wrangler.jsonc",
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
// @cloudflare/style-provider ships a hybrid ESM+CJS package: its es/ directory
|
|
// contains files that are nominally ESM but internally use require(). Vite 8's
|
|
// bundler (rolldown) mishandles this pattern and generates an anonymous,
|
|
// unreachable module initializer, leaving `createRenderer` as undefined at
|
|
// runtime (TypeError: createRenderer is not a function).
|
|
// Aliasing to the CJS build (lib/) avoids this — rolldown handles plain CJS
|
|
// correctly via its interop layer.
|
|
"@cloudflare/style-provider": "@cloudflare/style-provider/lib/index.js",
|
|
"react/jsx-runtime.js": "react/jsx-runtime",
|
|
},
|
|
},
|
|
|
|
appType: "spa",
|
|
build: {
|
|
chunkSizeWarningLimit: 1000,
|
|
// The application is actually hosted at `playground/`, but we can't use the `base` option.
|
|
// That would cause Vite to put the assets directly in `dist/assets` and to refer to them via `/playground/assets/` in the generated HTML.
|
|
// But Wrangler will upload the assets as though they were in `/assets` and so the links in the HTML would be broken.
|
|
// By keeping the assets in `dist/playground/assets`, the links in the HTML will match the actual location of the assets when deployed.
|
|
assetsDir: "playground/assets",
|
|
},
|
|
};
|
|
});
|