generated from Kazuki-tam/vitam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
115 lines (114 loc) · 2.8 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { defineConfig } from 'vite';
import handlebars from 'vite-plugin-handlebars';
import { resolve } from 'path';
import { siteData, pagesData } from './site.config';
import viteImagemin from 'vite-plugin-imagemin';
import { VitePWA } from 'vite-plugin-pwa';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import path from 'path';
export default defineConfig({
server: {
open: true,
},
root: siteData.root,
build: {
outDir: '../dist',
emptyOutDir: true,
rollupOptions: {
input: {
main: resolve(__dirname, siteData.root, 'index.html'),
sample: resolve(__dirname, siteData.root, 'sample/index.html'),
},
},
},
plugins: [
VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.svg', 'favicon.ico', 'robots.txt', 'apple-touch-icon.png'],
manifest: {
theme_color: siteData.themeColor,
background_color: siteData.themeColor,
display: 'browser',
name: siteData.siteName,
short_name: siteData.shortName,
description: siteData.description,
icons: [
{
src: '/pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/pwa-256x256.png',
sizes: '256x256',
type: 'image/png',
},
{
src: '/pwa-384x384.png',
sizes: '384x384',
type: 'image/png',
},
{
src: '/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
],
},
}),
viteImagemin({
gifsicle: {
optimizationLevel: 7,
interlaced: false,
},
optipng: {
optimizationLevel: 7,
},
mozjpeg: {
quality: 20,
},
pngquant: {
quality: [0.8, 0.9],
speed: 4,
},
svgo: {
plugins: [
{
name: 'removeViewBox',
},
{
name: 'removeEmptyAttrs',
active: false,
},
],
},
}),
handlebars({
partialDirectory: resolve(__dirname, siteData.root, '_partials'),
context(pagePath) {
return pagesData[pagePath];
},
}),
createSvgIconsPlugin({
// Specify the icon folder to be cached
iconDirs: [path.resolve(process.cwd(), 'src/icons')],
// Specify symbolId format
symbolId: 'icon-[dir]-[name]',
/**
* custom insert position
* @default: body-last
*/
/**
* custom dom id
* @default: __svg__icons__dom__
*/
customDomId: '__svg__icons__dom__',
}),
],
});