forked from mostafizurhimself/admintoolkit-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
88 lines (75 loc) · 2.08 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { defineConfig } from 'vite';
import { resolve } from 'path';
import glob from 'glob';
const entries = glob.sync('./src/**/*.html').reduce((acc, path) => {
const name = path.split('/').pop().split('.').shift();
acc[name] = path;
return acc;
}, {});
export default defineConfig({
root: 'src',
resolve: {
alias: {
'@tailwind.config': resolve(__dirname, './tailwind.config.js'),
'@': resolve(__dirname, './src'),
}
},
optimizeDeps: {
entries: Object.keys(entries),
},
build: {
target: 'esnext',
outDir: resolve(__dirname, 'dist'),
rollupOptions: {
input: entries,
output: {
assetFileNames: (chunkInfo) => {
let outDir = '';
// Fonts
if (/(ttf|woff|woff2|eot)$/.test(chunkInfo.name)) {
outDir = 'fonts';
}
// SVG
if (/svg$/.test(chunkInfo.name)) {
outDir = 'svg';
}
// Images
if (/(png|jpg|jpeg|gif|webp)$/.test(chunkInfo.name)) {
outDir = 'images';
}
// Media
if (/(mp3|mp4|webm|ogg|wav|flac|aac)$/.test(chunkInfo.name)) {
outDir += 'media';
}
// JSON
if (/json$/.test(chunkInfo.name)) {
outDir = 'json';
}
// JS
if (/js$/.test(chunkInfo.name)) {
outDir = 'js';
}
// CSS
if (/css$/.test(chunkInfo.name)) {
outDir = 'css';
}
return `${outDir}/[name][extname]`;
},
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js',
// manualChunks: (id) => {
// const fileName = id.split("/").pop();
// // if (id.includes("node_modules/")) {
// // return "plugins";
// // }
// // if (id.includes("components/")) {
// // return "components/" + fileName;
// // }
// // if (id.includes("custom/")) {
// // return "custom/" + fileName;
// // }
// },
}
},
},
});