-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
58 lines (54 loc) · 1.61 KB
/
Copy pathvite.config.ts
File metadata and controls
58 lines (54 loc) · 1.61 KB
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
import { defineConfig } from "vite";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import fs from "node:fs";
const __dirname = dirname(fileURLToPath(import.meta.url));
// Function to copy files to dist
const copyFile = (src: string, dest: string) => {
try {
fs.copyFileSync(src, dest);
console.log(`Copied ${src} to dist directory`);
} catch (error) {
console.error(`Error copying ${src}:`, error);
}
};
export default defineConfig({
build: {
emptyOutDir: true,
outDir: "dist",
minify: false,
sourcemap: false,
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
},
output: {
banner: "/*\n * find the original source code at https://github.com/breadles5/customhiterrorbar\n */",
entryFileNames: "[name].js",
chunkFileNames: "[name].js",
assetFileNames: "[name][extname]",
manualChunks: undefined,
},
},
target: "esnext",
},
base: "",
server: {
port: 3000,
strictPort: true,
host: true,
},
plugins: [
{
name: "copy-assets",
closeBundle() {
const files = ["metadata.txt", "settings.json"];
files.forEach((file) => {
const src = resolve(__dirname, file);
const dest = resolve(__dirname, "dist", file);
copyFile(src, dest);
});
},
},
],
});