-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
111 lines (105 loc) · 3.07 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
import Solid from 'solid-start/vite'
import Markdown from 'vite-plugin-solid-markdown'
import remarkGfm from 'remark-gfm'
import rehypePrettyCode from 'rehype-pretty-code'
import AutoImport from 'unplugin-auto-import/vite'
import { defineConfig } from 'vitest/config'
import Unocss from 'unocss/vite'
import { VitePWA } from 'vite-plugin-pwa'
import nodeAdapter from 'solid-start-node'
import staticAdapter from 'solid-start-static'
import netlifyAdapter from 'solid-start-netlify'
import vercelAdapter from 'solid-start-vercel'
import awsAdapter from 'solid-start-aws'
const adapterMap = {
node: nodeAdapter(),
static: staticAdapter(),
netlify: netlifyAdapter(),
vercel: vercelAdapter(),
aws: awsAdapter(),
}
const isTauri = process.env.TAURI === 'true'
export default defineConfig({
plugins: [
// https://github.com/xbmlzg/vite-plugin-solid-markdown
Markdown({
wrapperClasses: 'prose prose-sm m-auto text-left',
rehypePlugins: [
[
rehypePrettyCode,
{
theme: 'vitesse-dark',
},
],
],
remarkPlugins: [remarkGfm],
}),
// https://github.com/solidjs/solid-start
Solid({
extensions: ['.mdx', '.md'],
// @ts-expect-error - missing types
adapter: adapterMap[process.env.ADAPTER || 'static'],
ssr: !isTauri,
}),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: [
'solid-js',
{
'@solid-primitives/i18n': ['useI18n'],
},
],
dts: './src/auto-imports.d.ts',
}),
// https://github.com/unocss/unocss/tree/main/packages/vite
Unocss(),
// https://github.com/antfu/vite-plugin-pwa
isTauri
? undefined
: VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.svg', 'safari-pinned-tab.svg'],
manifest: {
name: 'Vitesse',
short_name: 'Vitesse',
theme_color: '#ffffff',
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: 'any maskable',
},
],
},
}),
],
ssr: {},
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ['VITE_', 'TAURI_'],
build: {
// Tauri supports es2021
target: ['es2021', 'chrome100', 'safari13'],
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
// produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG,
},
// https://github.com/vitest-dev/vitest
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['node_modules/@testing-library/jest-dom/extend-expect'],
},
})