-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
98 lines (93 loc) · 2.28 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
/// <reference types="vitest" />
import { defineConfig } from 'vite'
import { configDefaults } from 'vitest/config'
import solid from 'solid-start/vite'
// @ts-ignore
import deno from 'solid-start-deno'
// @ts-ignore
import staticMode from 'solid-start-static'
import tsconfigPaths from 'vite-tsconfig-paths'
import { VitePWA } from 'vite-plugin-pwa'
import replace, { RollupReplaceOptions } from '@rollup/plugin-replace'
import type { VitePWAOptions } from 'vite-plugin-pwa'
import AutoImport from 'unplugin-auto-import/vite'
// @ts-ignore
import type { Options as AutoImportOptions } from 'unplugin-auto-import'
const replaceOptions: Partial<RollupReplaceOptions> = {
__DATE__: new Date().toISOString(),
preventAssignment: true,
}
const pwaOptions: Partial<VitePWAOptions> = {
base: '/',
includeAssets: ['favicon.ico', 'robots.txt'],
manifest: {
name: 'bat',
short_name: 'bat',
description: 'Opinionated, batteries included, PWA using Solid and Vite',
theme_color: '#202A37',
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',
}
]
},
}
const autoImportOptions: Partial<AutoImportOptions> = {
imports: [
'solid-js',
{
'@solid-primitives/destructure': [
'destructure',
],
'@solid-primitives/i18n': [
'useI18n',
'createI18nContext',
],
'@testing-library/user-event': [
['default', 'userEvent'],
],
'@solidjs/meta': [
'Title',
],
},
],
}
const IS_TAURI = process && process.env.TAURI === '1'
export default defineConfig({
test: {
...configDefaults,
},
plugins: [
solid({ adapter: IS_TAURI ? staticMode() : deno() }),
tsconfigPaths(),
AutoImport(autoImportOptions),
IS_TAURI ? undefined : VitePWA(pwaOptions),
IS_TAURI ? undefined : replace(replaceOptions),
],
build: {
target: ['esnext'],
},
ssr: {
noExternal: [
'@motionone/solid',
'motion',
'solid-toast',
],
},
resolve: {
conditions: ['development', 'browser'],
},
})