2022-03-16 06:26:15 +00:00
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
import path from "path";
|
|
|
|
import { defineConfig, loadEnv } from "vite";
|
|
|
|
import checker from "vite-plugin-checker";
|
|
|
|
import chunks from "./config/chunks";
|
2022-03-17 04:01:22 +00:00
|
|
|
import overrideEnv from "./config/configReader";
|
2022-03-16 06:26:15 +00:00
|
|
|
|
|
|
|
export default defineConfig(async ({ mode, command }) => {
|
|
|
|
const env = loadEnv(mode, process.cwd());
|
|
|
|
|
2022-03-17 04:01:22 +00:00
|
|
|
if (command === "serve") {
|
|
|
|
await overrideEnv(env);
|
2022-03-16 06:26:15 +00:00
|
|
|
}
|
|
|
|
|
2022-03-17 04:01:22 +00:00
|
|
|
const target = env.VITE_PROXY_URL;
|
|
|
|
const ws = env.VITE_ALLOW_WEBSOCKET === "true";
|
|
|
|
const secure = env.VITE_PROXY_SECURE === "true";
|
|
|
|
|
2022-03-16 06:26:15 +00:00
|
|
|
return {
|
|
|
|
plugins: [
|
|
|
|
react(),
|
|
|
|
checker({
|
|
|
|
typescript: true,
|
|
|
|
eslint: {
|
|
|
|
files: ["./src"],
|
|
|
|
extensions: [".ts", ".tsx"],
|
|
|
|
},
|
|
|
|
enableBuild: false,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
base: "./",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
"@": path.resolve(__dirname, "./src"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
manifest: true,
|
|
|
|
sourcemap: mode === "development",
|
|
|
|
outDir: "./build",
|
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
manualChunks: chunks,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
proxy: {
|
|
|
|
"^/(api|images|test|bazarr.log)/.*": {
|
|
|
|
target,
|
|
|
|
changeOrigin: true,
|
|
|
|
secure,
|
2022-03-17 04:01:22 +00:00
|
|
|
ws,
|
2022-03-16 06:26:15 +00:00
|
|
|
},
|
|
|
|
},
|
2022-03-28 10:43:56 +00:00
|
|
|
host: true,
|
2022-03-16 06:26:15 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|