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({ alias({
entries: [ entries: [
{ find: '@main', replacement: join(__dirname, '../src/main'), }, { find: '@render', replacement: join(__dirname, '../src/render') },
{ find: '@root', replacement: join(__dirname, '..'), }, { 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 * electron
*/ */
import '@src/common/patch'
import { join } from 'path' import { join } from 'path'
import { app, BrowserWindow } from 'electron' import { app, BrowserWindow } from 'electron'
import dotenv from 'dotenv' import dotenv from 'dotenv'

View File

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

View File

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

View File

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