-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
56 lines (49 loc) · 1.36 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { sveltekit } from "@sveltejs/kit/vite";
import { loadEnv } from "vite";
import fs from "fs";
import path from "path";
const env = loadEnv("", process.cwd());
function copyLangFolderPlugin() {
let outDir = "";
return {
name: "copy-lang-folder",
apply: "build", // Run only during build
configResolved(config) {
// Get the output directory from Vite config
outDir = "build/";
},
async closeBundle() {
const srcDir = path.resolve(process.cwd(), "lang");
const destDir = path.resolve(process.cwd(), outDir, "lang");
if (!fs.existsSync(srcDir)) {
console.warn(`Source folder "lang" not found at: ${srcDir}`);
return;
}
try {
// Copy the "lang" folder recursively to the destination
await fs.promises.cp(srcDir, destDir, { recursive: true });
console.log(`Copied "lang" folder from ${srcDir} to ${destDir}`);
} catch (error) {
console.error("Error copying \"lang\" folder:", error);
}
}
};
}
/** @type {import('vite').UserConfig} */
const config = {
plugins: [
sveltekit(),
copyLangFolderPlugin()
],
ssr: {
noExternal: ["chart.js"],
},
server: {
proxy: {
"/api": env.VITE_API_URL.replace("/api", ""),
'/panel/api': env.VITE_API_URL.replace("/api", "")
},
allowedHosts: true
}
};
export default config;