Files
defgov/templates/vite-react-template/vite.config.ts

44 lines
978 B
TypeScript

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import dts from "vite-plugin-dts";
import path from "path";
import { genIndexTsPlugin } from "./scripts-plugin/vite-plugin-gen-index-ts";
import { genIndexCssPlugin } from "./scripts-plugin/vite-plugin-gen-index-css";
export default defineConfig({
plugins: [
genIndexTsPlugin(),
genIndexCssPlugin(),
react(),
dts({
insertTypesEntry: true,
}),
],
build: {
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
name: "DefgovUIWeb",
formats: ["es", "cjs"],
fileName: (format) => `index.${format}.js`,
},
rollupOptions: {
external: ["react", "react-dom", "react/jsx-runtime"],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
},
},
},
sourcemap: true,
cssCodeSplit: true,
watch: {
exclude: ["node_modules", "dist", ".git"],
},
},
});