Generated types for the react package were broken because they were still using absolute imports which cannot work in standalone .d.ts files because they cannot rely on the local baseUrl compiler option. Thus, we introduced an alias that we are able to reliably replace during type generation.
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import { resolve } from "path";
|
|
import { defineConfig } from "vitest/config";
|
|
import react from "@vitejs/plugin-react";
|
|
import dts from "vite-plugin-dts";
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
build: {
|
|
emptyOutDir: true,
|
|
outDir: "dist",
|
|
sourcemap: true,
|
|
lib: {
|
|
entry: {
|
|
index: "./src/index.ts",
|
|
},
|
|
formats: ["es"],
|
|
},
|
|
rollupOptions: {
|
|
external: ["react", "react-dom"],
|
|
output: {
|
|
globals: {
|
|
react: "React",
|
|
"react-dom": "ReactDOM",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
plugins: [tsconfigPaths(), dts(), react()],
|
|
test: {
|
|
environment: "jsdom",
|
|
reporters: "verbose",
|
|
globals: true,
|
|
watchExclude: ["**/cunningham-tokens.js"],
|
|
coverage: {
|
|
all: true,
|
|
include: ["src/**/*.{ts,tsx}"],
|
|
exclude: ["**/*.stories.tsx", "**/*.spec.tsx"],
|
|
},
|
|
setupFiles: ["src/tests/Setup.ts"],
|
|
},
|
|
resolve: {
|
|
alias: [
|
|
{
|
|
find: ":",
|
|
replacement: resolve(__dirname, "./src"),
|
|
},
|
|
],
|
|
},
|
|
});
|