-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
60 lines (54 loc) · 1.66 KB
/
vite.config.ts
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
57
58
59
60
import { defineConfig, loadEnv } from "vite";
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";
import path from "path";
import { exit } from "process";
export default defineConfig(({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), "") };
// Εύρεση resource path από το APP_URL
let resources_dir;
let index = 0;
let app_url = process.env.APP_URL;
if (typeof app_url === "undefined") {
console.error("APP_URL is not defined! Aborting...");
exit(2);
}
index = app_url.indexOf("//");
if (index === -1) {
console.log("Σφάλμα με τον ορισμό του APP_URL στο .env!");
process.exit(1);
}
index = app_url.indexOf("/", index + 2);
if (index === -1) {
resources_dir = "/";
} else {
resources_dir = app_url.substring(index);
if (!resources_dir.endsWith("/")) {
resources_dir += "/";
}
}
console.log("==", resources_dir);
process.env.ASSET_URL = resources_dir;
return {
plugins: [
laravel({
input: "resources/ts/app.ts",
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "resources/ts/"),
"ziggy-js": path.resolve(__dirname, "vendor/tightenco/ziggy/"),
},
},
};
});