-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
80 lines (78 loc) · 1.92 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { defineConfig } from 'vite'
import { join } from 'path'
import vue from '@vitejs/plugin-vue'
import { svgBuilder } from './src/plugins/svgSprite'
import WindiCSS from 'vite-plugin-windicss'
import Components from 'vite-plugin-components'
import ViteIcons, { ViteIconsResolver } from 'vite-plugin-icons'
import legacy from '@vitejs/plugin-legacy'
import { minifyHtml } from 'vite-plugin-html'
const renderRoutes = (() => {
const routes = [
'/',
'/about',
'/affairs-info',
'/chart-info'
].map((route) => route.replace(/\/$/, ''))
routes.push(...routes.map((route) => `${route}/`))
return routes
})()
export default defineConfig({
resolve: {
alias: {
'@': `${join(__dirname, 'src')}`,
src: `${join(__dirname, 'src')}`
}
},
plugins: [
vue(),
svgBuilder('./src/assets/svg/'),
Components({
customComponentResolvers: ViteIconsResolver({
componentPrefix: 'icon'
})
}),
ViteIcons(),
WindiCSS(),
legacy({
targets: ['defaults', 'dead', '> 1%', 'ie 10', 'ie 6', 'ie 7', 'ie 8', 'ie 9', 'ie 11', 'since 2002', 'unreleased versions']
}),
minifyHtml({
collapseBooleanAttributes: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
minifyURLs: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true
})
],
build: {
minify: 'terser',
brotliSize: true,
cssCodeSplit: true,
terserOptions: {
sourceMap: false,
ecma: 5,
ie8: true,
safari10: true,
keep_classnames: false,
keep_fnames: false,
compress: true
}
},
esbuild: {
include: './src/**/*.{js,ts,jsx,tsx,css,json,text,base64,dataurl,file,binary}'
},
ssgOptions: {
script: 'async',
formatting: 'minify',
includedRoutes () {
return renderRoutes
},
onPageRendered: (r, html) => {
return html
}
}
})