fix: ensure process.cwd() correct.

This commit is contained in:
草鞋没号 2021-05-15 20:57:32 +08:00
parent f6f363364d
commit d5f294cd2a
6 changed files with 15 additions and 9 deletions

View File

@ -25,8 +25,10 @@ export default (env = 'production') => {
}),
alias({
entries: [
{ find: '@main', replacement: join(__dirname, '../src/main'), },
{ find: '@root', replacement: join(__dirname, '..'), },
{ find: '@render', replacement: join(__dirname, '../src/render') },
{ find: '@main', replacement: join(__dirname, '../src/main') },
{ find: '@src', replacement: join(__dirname, '../src') },
{ find: '@root', replacement: join(__dirname, '..') },
]
}),
],

4
src/common/patch.ts Normal file
View File

@ -0,0 +1,4 @@
/**
* !!! ensure process.cwd() correct
*/
process.chdir(__dirname.slice(0, __dirname.lastIndexOf('dist')))

View File

@ -1,6 +1,7 @@
/**
* electron
*/
import '@src/common/patch'
import { join } from 'path'
import { app, BrowserWindow } from 'electron'
import dotenv from 'dotenv'

View File

@ -1,8 +1,4 @@
/**
* !!! ensure cwd crrect
*/
process.chdir(__dirname)
import '@src/common/patch'
import { createApp } from 'vue'
import App from './App.vue'
import fs = require('fs')

View File

@ -11,8 +11,9 @@
"baseUrl": "./",
"strict": true,
"paths": {
"@/*": ["src/render/*"],
"@render/*": ["src/render/*"],
"@main/*": ["src/main/*"],
"@src/*": ["src/*"],
"@root/*": ["./*"]
},
"allowSyntheticDefaultImports": true

View File

@ -18,7 +18,9 @@ export default defineConfig({
},
resolve: {
alias: {
'@': join(__dirname, 'src/render'),
'@render': join(__dirname, 'src/render'),
'@main': join(__dirname, 'src/main'),
'@src': join(__dirname, 'src'),
'@root': __dirname,
},
},