-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
40 lines (37 loc) · 1.02 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
import { defineConfig } from "vite";
import { resolve } from "path";
import fs from "fs";
function generateInputObject(path) {
const resolvedPath = resolve(__dirname, path);
const isDirectory = fs.statSync(resolvedPath).isDirectory();
if (isDirectory) {
return fs.readdirSync(resolvedPath).reduce((acc, file) => {
const name = file.split(".").shift(); // Use the file name without extension as the key
acc[name] = resolve(resolvedPath, file);
return acc;
}, {});
} else {
const name = path.split("/").pop().split(".").shift(); // Extract the file name without extension
return { [name]: resolvedPath };
}
}
export default defineConfig({
root: "./src",
publicDir: "../src/public",
build: {
outDir: "../dist",
emptyOutDir: true,
sourcemap: false,
rollupOptions: {
input: {
index: resolve(__dirname, "./src/index.html"),
...generateInputObject("./src/pages"),
},
},
},
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
});