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
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import { resolve } from "node:path";
|
|
import react from "@vitejs/plugin-react";
|
|
import { defineConfig } from "vite";
|
|
import dts from "vite-plugin-dts";
|
|
import type { Plugin } from "vite";
|
|
|
|
// See https://github.com/facebook/create-react-app/issues/11769
|
|
// Turn react/jsx-runtime imports into react/jsx-runtime.js
|
|
function addJsxRuntimeExtension(): Plugin {
|
|
return {
|
|
name: "jsx-runtime-extension",
|
|
enforce: "pre",
|
|
resolveId(source) {
|
|
if (source === "react/jsx-runtime") {
|
|
return {
|
|
id: "react/jsx-runtime.js",
|
|
external: true,
|
|
};
|
|
}
|
|
return null;
|
|
},
|
|
};
|
|
}
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react(), dts(), addJsxRuntimeExtension()],
|
|
build: {
|
|
chunkSizeWarningLimit: 1000,
|
|
lib: {
|
|
entry: resolve(__dirname, "lib/index.ts"),
|
|
formats: ["es"],
|
|
fileName: "index",
|
|
},
|
|
rollupOptions: {
|
|
external: [
|
|
"react",
|
|
// react/jsx-runtime is externalised by the addJsxRuntimeExtension() plugin
|
|
"@cloudflare/style-container",
|
|
"@cloudflare/style-const",
|
|
],
|
|
},
|
|
},
|
|
});
|