forked from open-pencil/open-pencil
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
108 lines (102 loc) · 3.24 KB
/
vite.config.ts
File metadata and controls
108 lines (102 loc) · 3.24 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
import { resolve } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Components from 'unplugin-vue-components/vite'
import { VitePWA } from 'vite-plugin-pwa'
import { copyFileSync, existsSync, mkdirSync } from 'fs'
import { automationPlugin } from './src/automation/vite-plugin'
// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST
export default defineConfig(async () => ({
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
shiki: resolve(__dirname, 'src/shims/shiki.ts')
}
},
plugins: [
{
name: 'copy-canvaskit-wasm',
buildStart() {
const src = 'node_modules/canvaskit-wasm/bin/canvaskit.wasm'
const dest = 'public/canvaskit.wasm'
if (existsSync(src) && !existsSync(dest)) {
copyFileSync(src, dest)
}
const webgpuSrc = 'packages/core/vendor/canvaskit-webgpu/canvaskit.wasm'
const webgpuDir = 'public/canvaskit-webgpu'
const webgpuDest = `${webgpuDir}/canvaskit.wasm`
if (existsSync(webgpuSrc) && !existsSync(webgpuDest)) {
mkdirSync(webgpuDir, { recursive: true })
copyFileSync(webgpuSrc, webgpuDest)
}
const webgpuJsSrc = 'packages/core/vendor/canvaskit-webgpu/canvaskit.js'
const webgpuJsDest = `${webgpuDir}/canvaskit.js`
if (existsSync(webgpuJsSrc) && !existsSync(webgpuJsDest)) {
mkdirSync(webgpuDir, { recursive: true })
copyFileSync(webgpuJsSrc, webgpuJsDest)
}
}
},
tailwindcss(),
Icons({ compiler: 'vue3' }),
Components({ resolvers: [IconsResolver({ prefix: 'icon' })] }),
automationPlugin(),
vue(),
VitePWA({
registerType: 'autoUpdate',
devOptions: { enabled: false },
workbox: {
maximumFileSizeToCacheInBytes: 8 * 1024 * 1024,
globPatterns: ['**/*.{js,css,html,wasm,png,ico,ttf,webmanifest}'],
navigateFallback: '/index.html'
},
manifest: {
name: 'OpenPencil',
short_name: 'OpenPencil',
description: 'Open-source design editor',
display: 'standalone',
orientation: 'any',
start_url: '/',
scope: '/',
theme_color: '#1e1e1e',
background_color: '#1e1e1e',
categories: ['design', 'productivity'],
icons: [
{ src: '/pwa-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' },
{ src: '/pwa-512.png', sizes: '512x512', type: 'image/png', purpose: 'any' },
{ src: '/pwa-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' }
]
}
})
],
clearScreen: false,
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: 'ws',
host,
port: 1421
}
: undefined,
watch: {
ignored: [
'**/desktop/**',
'**/packages/cli/**',
'**/packages/mcp/**',
'**/packages/docs/**',
'**/tests/**',
'**/openspec/**',
'**/.worktrees/**',
'**/.github/**',
'**/.pi/**'
]
}
}
}))