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
|
|
|
|
2024-03-04 12:38:28 +00:00
|
|
|
import { getRootPath } from "./src/utils/getRootPath";
|
|
|
|
|
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-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: {
|
|
|
|
port: 8080,
|
2024-03-04 12:38:28 +00:00
|
|
|
open: getRootPath(),
|
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",
|
|
|
|
rollupOptions: {
|
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
|
|
|
});
|