-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
54 lines (50 loc) · 1.18 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
/** @type {import('vite').UserConfig} */
import tailwindcss from '@tailwindcss/vite'
import pug from '@vituum/vite-plugin-pug'
import { join, resolve } from 'node:path'
import vituum from 'vituum'
import dataSite from './src/data/site'
const __dirname = resolve()
export default {
publicDir: join(__dirname, 'public'),
plugins: [
tailwindcss(),
vituum(),
pug({
root: join(__dirname, 'src'),
globals: {
site: dataSite,
},
}),
],
build: {
manifest: false,
assetsInlineLimit: 0,
modulePreload: false,
rollupOptions: {
input: [
'./src/pages/**/*.{json,pug,html}',
'!./src/pages/**/*.pug.json',
'./src/scripts/*.{js,ts,mjs}',
],
output: {
entryFileNames: 'assets/js/[name].js',
chunkFileNames: 'assets/js/[name].js',
assetFileNames: getFileName,
},
},
},
server: {
port: 8080,
},
}
function getFileName(assetInfo) {
let extType = assetInfo.name.split('.').pop()
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) {
extType = 'images'
}
if (/ttf|eot|woff2?/i.test(extType)) {
extType = 'fonts'
}
return `assets/${extType}/[name][extname]`
}