forked from asadahimeka/booruwf-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
119 lines (118 loc) · 3.75 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
116
117
118
119
import { URL, fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'
import { createVuePlugin as Vue2 } from 'vite-plugin-vue2'
import { createHtmlPlugin as Html } from 'vite-plugin-html'
import { viteExternalsPlugin as Externals } from 'vite-plugin-externals'
import ScriptSetup from 'unplugin-vue2-script-setup/vite'
import { VitePWA } from 'vite-plugin-pwa'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
// https://github.com/underfin/vite-plugin-vue2
Vue2({ target: 'esnext' }),
// https://github.com/crcong/vite-plugin-externals
Externals({
'vue': 'Vue',
'vuetify': 'Vuetify',
'@vue/composition-api': 'VueCompositionAPI',
'vue-masonry-css': 'VueMasonry',
}, { disableInServe: true }),
// https://github.com/vbenjs/vite-plugin-html
Html({
minify: true,
entry: 'src/main.ts',
inject: {
data: {
cdnCss: [
'https://unpkg.com/normalize.css@8.0.1/normalize.css',
'https://fonts.loli.net/css?family=Roboto:100,300,400,500,700,900',
'https://unpkg.com/vuetify@2.6.14/dist/vuetify.min.css',
],
cdnJs: [
'https://unpkg.com/vue@2.6.14/dist/vue.min.js',
'https://unpkg.com/@vue/composition-api@1.7.1/dist/vue-composition-api.prod.js',
'https://unpkg.com/vuetify@2.6.14/dist/vuetify.min.js',
'https://unpkg.com/vue-masonry-css@1.0.3/dist/vue-masonry.min.js',
],
},
},
}),
// https://github.com/antfu/unplugin-vue2-script-setup
ScriptSetup(),
// https://github.com/antfu/vite-plugin-pwa
VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'pwa-192x192.png', 'pwa-256x256.png'],
manifestFilename: 'manifest.json',
manifest: {
name: 'Booru Masonry',
short_name: 'booruwf',
description: 'Browsing booru sites with masonry layout.',
theme_color: '#B28FCE',
icons: [
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-256x256.png',
sizes: '256x256',
type: 'image/png',
},
],
},
workbox: {
skipWaiting: true,
clientsClaim: true,
runtimeCaching: [
{
urlPattern: /.*\.html$/,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'html-cache',
cacheableResponse: { statuses: [0, 200] },
},
},
{
urlPattern: /.*\.(css|js)$/,
handler: 'CacheFirst',
options: {
cacheName: 'css-js-cache',
cacheableResponse: { statuses: [0, 200] },
},
},
{
urlPattern: /.*\.(png|gif|jpg|jpeg|ico|svg|mp4)$/,
handler: 'CacheFirst',
options: {
cacheName: 'media-cache',
cacheableResponse: { statuses: [0, 200] },
},
},
{
urlPattern: /.*(\/post\.json|\/index\.php|\/index\.xml).*/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
cacheableResponse: { statuses: [0, 200] },
},
},
{
urlPattern: /^https:\/\/(lib\.baomitu\.com|unpkg\.com|loli\.net|googleapis\.com|code\.bdstatic\.com)\/.*/,
handler: 'CacheFirst',
options: {
cacheName: 'cdn-cache',
cacheableResponse: { statuses: [0, 200] },
},
},
],
},
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('src', import.meta.url)),
},
},
})