refactor: use watch.mjs in .debug.script.mjs
This commit is contained in:
1 parent
1651b5dd2a
commit
9336e41591
2 files changed
+15
-54
No files matched your search
Vendored
+1
-47
@@ -1,47 +1 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { createRequire } from 'module'
|
||||
import { build, createServer } from 'vite'
|
||||
|
||||
const pkg = createRequire(import.meta.url)('../package.json')
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
async function buildDebugApp() {
|
||||
const server = await createServer({ configFile: 'packages/renderer/vite.config.ts' })
|
||||
|
||||
await server.listen()
|
||||
|
||||
await build({
|
||||
configFile: 'packages/preload/vite.config.ts',
|
||||
build: {
|
||||
watch: true,
|
||||
sourcemap: true,
|
||||
},
|
||||
mode: 'development',
|
||||
})
|
||||
|
||||
await build({
|
||||
configFile: 'packages/main/vite.config.ts',
|
||||
build: {
|
||||
watch: true,
|
||||
sourcemap: true,
|
||||
},
|
||||
mode: 'development',
|
||||
plugins: [{
|
||||
name: 'electron-preload-watcher',
|
||||
writeBundle() {
|
||||
server.ws.send({ type: 'full-reload' })
|
||||
},
|
||||
}],
|
||||
})
|
||||
}
|
||||
|
||||
function writeEnvLocal() {
|
||||
const envContent = Object.entries(pkg.env).map(([key, val]) => `${key}=${val}`)
|
||||
fs.writeFileSync(path.join(__dirname, '.debug.env'), envContent.join('\n'))
|
||||
}
|
||||
|
||||
// bootstrap
|
||||
writeEnvLocal()
|
||||
buildDebugApp()
|
||||
import '../scripts/watch.mjs?debug=vscode'
|
||||
Reference in new issue
Block a user