2023-02-14 15:57:58 +00:00
|
|
|
import react from "@vitejs/plugin-react-swc";
|
2024-02-01 15:46:11 +00:00
|
|
|
import path from "path";
|
|
|
|
import { defineConfig, loadEnv } from "vite";
|
2022-11-18 16:13:39 +00:00
|
|
|
import { checker } from "vite-plugin-checker";
|
2024-02-20 14:46:21 +00:00
|
|
|
import dts from "vite-plugin-dts";
|
2022-10-10 10:14:19 +00:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
2024-02-01 15:46:11 +00:00
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
|
|
const external = ["react", "react/jsx-runtime", "react-dom"];
|
2024-02-20 14:46:21 +00:00
|
|
|
const plugins = [react(), checker({ typescript: true })];
|
|
|
|
if (env.LIB) {
|
|
|
|
external.push("react-router-dom");
|
|
|
|
external.push("react-i18next");
|
|
|
|
plugins.push(dts({ insertTypesEntry: true }));
|
|
|
|
}
|
2024-02-01 15:46:11 +00:00
|
|
|
const lib = env.LIB
|
|
|
|
? {
|
2024-06-12 12:22:06 +00:00
|
|
|
copyPublicDir: false,
|
2024-04-19 18:10:34 +00:00
|
|
|
outDir: "lib",
|
2024-02-01 15:46:11 +00:00
|
|
|
lib: {
|
|
|
|
entry: path.resolve(__dirname, "src/index.ts"),
|
|
|
|
formats: ["es"],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: undefined;
|
|
|
|
return {
|
|
|
|
base: "",
|
|
|
|
server: {
|
2024-06-12 09:55:14 +00:00
|
|
|
origin: "http://localhost:5173",
|
|
|
|
port: 5173,
|
2023-11-20 16:34:03 +00:00
|
|
|
},
|
2024-02-01 15:46:11 +00:00
|
|
|
build: {
|
|
|
|
...lib,
|
|
|
|
sourcemap: true,
|
|
|
|
target: "esnext",
|
|
|
|
modulePreload: false,
|
|
|
|
cssMinify: "lightningcss",
|
2024-06-12 09:55:14 +00:00
|
|
|
manifest: true,
|
2024-02-01 15:46:11 +00:00
|
|
|
rollupOptions: {
|
2024-06-12 09:55:14 +00:00
|
|
|
input: "src/main.tsx",
|
2024-04-19 18:10:34 +00:00
|
|
|
external,
|
2024-02-01 15:46:11 +00:00
|
|
|
},
|
|
|
|
},
|
2024-02-20 14:46:21 +00:00
|
|
|
plugins,
|
2024-02-01 15:46:11 +00:00
|
|
|
};
|
2022-10-10 10:14:19 +00:00
|
|
|
});
|