99d3611afe
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import react from "@vitejs/plugin-react-swc";
|
|
import path from "path";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
import { checker } from "vite-plugin-checker";
|
|
import dts from "vite-plugin-dts";
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
const external = ["react", "react/jsx-runtime", "react-dom"];
|
|
const plugins = [react(), checker({ typescript: true })];
|
|
if (env.LIB) {
|
|
external.push("react-router-dom");
|
|
external.push("react-i18next");
|
|
plugins.push(dts({ insertTypesEntry: true }));
|
|
}
|
|
const lib = env.LIB
|
|
? {
|
|
copyPublicDir: false,
|
|
outDir: "lib",
|
|
lib: {
|
|
entry: path.resolve(__dirname, "src/index.ts"),
|
|
formats: ["es"],
|
|
},
|
|
}
|
|
: undefined;
|
|
return {
|
|
base: "",
|
|
server: {
|
|
origin: "http://localhost:5173",
|
|
port: 5173,
|
|
},
|
|
build: {
|
|
...lib,
|
|
sourcemap: true,
|
|
target: "esnext",
|
|
modulePreload: false,
|
|
cssMinify: "lightningcss",
|
|
manifest: true,
|
|
rollupOptions: {
|
|
input: "src/main.tsx",
|
|
external,
|
|
},
|
|
},
|
|
plugins,
|
|
};
|
|
});
|