-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathvite.config.ts
54 lines (50 loc) · 1.43 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
import { spawnSync } from 'node:child_process'
import { existsSync, readFileSync } from 'node:fs'
import path from 'node:path'
import Vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import { defineConfig } from 'vite'
let oxcCommit: string | undefined
const COMMIT_FILE = '../oxc/napi/playground/git-commit'
if (existsSync(COMMIT_FILE)) {
oxcCommit = readFileSync('../oxc/napi/playground/git-commit', 'utf8').trim()
}
if (!oxcCommit) {
const { stdout } = spawnSync('git', ['rev-parse', '--short', 'HEAD'], {
cwd: '../oxc/napi/playground',
encoding: 'utf8',
})
oxcCommit = stdout.trim()
}
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'~': path.resolve(__dirname, './src'),
},
},
define: {
'import.meta.env.OXC_COMMIT': JSON.stringify(oxcCommit),
},
build: {
target: 'esnext',
},
optimizeDeps: {
esbuildOptions: {
target: 'esnext',
},
},
server: {
// These two cross origin headers are used to fix the following error:
// TypeError: Failed to execute 'decode' on 'TextDecoder': The provided ArrayBufferView value must not be shared.
// The same headers are added to netlify via `dist/_headers`
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
fs: {
allow: [__dirname, '../oxc/napi/playground'],
},
},
plugins: [Vue(), UnoCSS()],
})