-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
145 lines (141 loc) · 5.15 KB
/
vite.config.ts
File metadata and controls
145 lines (141 loc) · 5.15 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { fileURLToPath, URL } from 'node:url'
import UnocssVitePlugin from 'unocss/vite'
import Components from 'unplugin-vue-components/vite'
import Vue from 'unplugin-vue/rolldown'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
import Layouts from 'vite-plugin-vue-layouts-next'
import generateSitemap from 'vite-ssg-sitemap'
import VueRouter from 'vue-router/vite'
// Types
import type { ViteSSGOptions } from 'vite-ssg'
import { getApiSlugs } from './build/api-names'
import copyMarkdownPlugin from './build/copy-markdown'
import generateApiPlugin from './build/generate-api'
import generateApiWhitelistPlugin from './build/generate-api-whitelist'
import generateExamplesPlugin from './build/generate-examples'
import generateLlmsFullPlugin from './build/generate-llms-full'
import generateNavPlugin from './build/generate-nav'
import { generateOgImages } from './build/generate-og-images'
import generatePageDatesPlugin from './build/generate-page-dates'
import generateSearchIndexPlugin from './build/generate-search-index'
import Markdown from './build/markdown'
import { getSkillzSlugs } from './build/skillz-tours'
import pkg from './package.json' with { type: 'json' }
export default defineConfig({
optimizeDeps: {
exclude: ['@vue/repl', 'monaco-editor'],
},
ssr: {
noExternal: ['@vue/repl'],
},
build: {
sourcemap: true,
},
css: {
transformer: 'postcss', // Use postcss instead of lightningcss to preserve color-mix syntax
},
ssgOptions: {
// Disable beasties critical CSS extraction. Beasties inconsistently inlines
// UnoCSS utilities (some classes get inlined, others don't) causing layout
// shift when the external CSS loads. With this disabled, CSS loads as a
// blocking resource - all styles available before first paint, zero CLS.
beastiesOptions: false,
dirStyle: 'nested',
async includedRoutes (paths) {
const [apiSlugs, skillzSlugs] = await Promise.all([
getApiSlugs(),
getSkillzSlugs(),
])
const apiRoutes = apiSlugs.map(slug => `/api/${slug}`)
const skillzRoutes = skillzSlugs.map(slug => `/skillz/${slug}`)
return [...paths, ...apiRoutes, ...skillzRoutes]
},
async onFinished () {
generateSitemap({
hostname: 'https://0.vuetifyjs.com',
generateRobotsTxt: false,
changefreq: 'daily',
priority: 0.7,
})
await generateOgImages()
},
} as ViteSSGOptions,
plugins: [
generateApiWhitelistPlugin(),
VueRouter({
dts: './src/typed-router.d.ts',
extensions: ['.vue', '.md'],
}),
Vue({
include: [/\.vue$/, /\.md$/],
}),
await Markdown(),
Components({
dirs: ['src/components'],
extensions: ['vue'],
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
dts: './src/components.d.ts',
}),
UnocssVitePlugin(),
Layouts(),
copyMarkdownPlugin(),
generateApiPlugin(),
generateExamplesPlugin(),
generateLlmsFullPlugin(),
generateSearchIndexPlugin(),
generateNavPlugin(),
generatePageDatesPlugin(),
VitePWA({
injectRegister: 'script-defer',
registerType: 'autoUpdate',
manifest: {
name: 'Vuetify0',
short_name: 'v0',
description: 'Headless UI primitives and composables for Vue',
theme_color: '#1867C0',
background_color: '#121212',
display: 'standalone',
icons: [
{ src: '/pwa-192x192.png', sizes: '192x192', type: 'image/png' },
{ src: '/pwa-512x512.png', sizes: '512x512', type: 'image/png' },
{ src: '/pwa-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
],
},
workbox: {
globPatterns: ['**/*.{js,css,ico,png,svg,woff2}'],
// Exclude mermaid diagram chunks from precache (loaded on demand)
// Exclude large on-demand chunks from precache
// - Mermaid/Cytoscape: diagram tools, loaded only when docs use them
// - vue.worker/playground/jsx: Monaco editor assets, only needed in the playground
globIgnores: ['**/*Diagram-*.js', '**/mermaid*.js', '**/cytoscape*.js', '**/vue.worker*.js', '**/playground-*.js', '**/jsx-*.js', '**/monaco-editor-*.js'],
navigateFallback: null,
},
}),
],
define: {
'process.env': {},
'__DEV__': process.env.NODE_ENV !== 'production',
'__VERSION__': JSON.stringify(pkg.version),
'__VITE_LOGGER_ENABLED__': process.env.VITE_LOGGER_ENABLED,
'__VUE_OPTIONS_API__': 'true',
'__VUE_PROD_DEVTOOLS__': 'false',
'__VUE_PROD_HYDRATION_MISMATCH_DETAILS__': 'false',
},
resolve: {
alias: {
'@': fileURLToPath(new URL('src', import.meta.url)),
'@build': fileURLToPath(new URL('build', import.meta.url)),
'@vuetify/v0': fileURLToPath(new URL('../../packages/0/src', import.meta.url)),
'@vuetify/paper': fileURLToPath(new URL('../../packages/paper/src', import.meta.url)),
// internal
'#v0': fileURLToPath(new URL('../../packages/0/src', import.meta.url)),
'#paper': fileURLToPath(new URL('../../packages/paper/src', import.meta.url)),
},
},
server: {
fs: {
allow: ['../../packages/*', '../../node_modules', '.'],
},
},
})