initialize Electron desktop app and remove unused files
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { defineConfig, type Plugin } from 'vitest/config'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { resolve } from 'path'
|
||||
|
||||
/**
|
||||
* Vite 的 SSR 变换用 `/^#!.*\n/` 识别 shebang,并把 import 声明提升到它前面。
|
||||
* 这个正则只在 LF 工作区成立:`.` 不匹配 `\r`,所以 CRLF checkout(Windows 默认
|
||||
* core.autocrlf=true)下 shebang 识别失败,import 被提升到 `#!/usr/bin/env node`
|
||||
* 之前,shebang 落到文件中部,运行期直接抛 "Invalid or unexpected token"。
|
||||
*
|
||||
* 统一在 SSR 变换之前剥掉 shebang:它只对「直接执行」有意义,测试里不需要。
|
||||
*/
|
||||
function stripShebang(): Plugin {
|
||||
return {
|
||||
name: 'hermes:strip-shebang',
|
||||
enforce: 'pre',
|
||||
transform(code, id) {
|
||||
if (!code.startsWith('#!')) return null
|
||||
const newline = code.indexOf('\n')
|
||||
return { code: newline === -1 ? '' : code.slice(newline + 1), map: null }
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [stripShebang(), vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'packages/client/src'),
|
||||
'/logo.png': resolve(__dirname, 'packages/client/public/logo.png'),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
include: ['tests/**/*.test.ts'],
|
||||
setupFiles: ['tests/setup.ts'],
|
||||
coverage: {
|
||||
// Without an explicit include, v8 coverage walks the whole project root.
|
||||
// While the read-only reference_code/ checkout was present that pulled in
|
||||
// ~570 of its files and diluted every percentage below.
|
||||
provider: 'v8',
|
||||
include: ['packages/*/src/**'],
|
||||
exclude: ['**/vendor/**', '**/*.d.ts'],
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user