mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
refactor: better Debug
This commit is contained in:
parent
5b21e8f189
commit
ebb226e917
2
.vscode/.debug.script.mjs
vendored
2
.vscode/.debug.script.mjs
vendored
@ -8,7 +8,7 @@ const pkg = createRequire(import.meta.url)('../package.json')
|
|||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
// write .debug.env
|
// write .debug.env
|
||||||
const envContent = Object.entries(pkg.env).map(([key, val]) => `${key}=${val}`)
|
const envContent = Object.entries(pkg.debug.env).map(([key, val]) => `${key}=${val}`)
|
||||||
fs.writeFileSync(path.join(__dirname, '.debug.env'), envContent.join('\n'))
|
fs.writeFileSync(path.join(__dirname, '.debug.env'), envContent.join('\n'))
|
||||||
|
|
||||||
// bootstrap
|
// bootstrap
|
||||||
|
@ -28,8 +28,7 @@ export const ROOT_PATH = {
|
|||||||
let win: BrowserWindow | null = null
|
let win: BrowserWindow | null = null
|
||||||
// Here, you can also use other preload
|
// Here, you can also use other preload
|
||||||
const preload = join(__dirname, '../preload/index.js')
|
const preload = join(__dirname, '../preload/index.js')
|
||||||
// 🚧 Use ['ENV_NAME'] avoid vite:define plugin
|
const url = process.env.VITE_DEV_SERVER_URL
|
||||||
const url = `http://${process.env['VITE_DEV_SERVER_HOST']}:${process.env['VITE_DEV_SERVER_PORT']}`
|
|
||||||
const indexHtml = join(ROOT_PATH.dist, 'index.html')
|
const indexHtml = join(ROOT_PATH.dist, 'index.html')
|
||||||
|
|
||||||
async function createWindow() {
|
async function createWindow() {
|
||||||
|
@ -23,9 +23,12 @@
|
|||||||
"vue": "^3.2.37",
|
"vue": "^3.2.37",
|
||||||
"vue-tsc": "^0.40.1"
|
"vue-tsc": "^0.40.1"
|
||||||
},
|
},
|
||||||
|
"debug": {
|
||||||
"env": {
|
"env": {
|
||||||
"VITE_DEV_SERVER_HOST": "127.0.0.1",
|
"VITE_DEV_SERVER_HOST": "127.0.0.1",
|
||||||
"VITE_DEV_SERVER_PORT": 3344
|
"VITE_DEV_SERVER_PORT": 3344,
|
||||||
|
"VITE_DEV_SERVER_URL": "http://127.0.0.1:3344"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"electron",
|
"electron",
|
||||||
|
@ -42,8 +42,8 @@ export default defineConfig({
|
|||||||
renderer: {},
|
renderer: {},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
server: {
|
server: process.env.VSCODE_DEBUG ? {
|
||||||
host: pkg.env.VITE_DEV_SERVER_HOST,
|
host: pkg.debug.env.VITE_DEV_SERVER_HOST,
|
||||||
port: pkg.env.VITE_DEV_SERVER_PORT,
|
port: pkg.debug.env.VITE_DEV_SERVER_PORT,
|
||||||
},
|
} : undefined,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user