pack: fix test build
This commit is contained in:
1 parent
72a684b35c
commit
7da4d76ad8
3 files changed
+52
-41
No files matched your search
+1
-1
@@ -19,7 +19,7 @@
|
||||
"dev:debug": "vite -d",
|
||||
"dev:debug:force": "vite -d --force",
|
||||
"build": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js",
|
||||
"build:pre": "npm run format:fix && vue-tsc --noEmit && vite build",
|
||||
"build:pre": "npm run format:fix && vue-tsc --noEmit && cross-env NODE_ENV=production vite build",
|
||||
"build:all": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js -wml",
|
||||
"build:dir": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js --dir",
|
||||
"build:mac": "npm run build:pre && CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder --config=buildAssets/builder/config.js --mac",
|
||||
|
||||
+9
-1
@@ -19,7 +19,15 @@ function existElementByTestId(selector: string, waitingMilliseconds = 100) {
|
||||
|
||||
test.beforeAll(async () => {
|
||||
// Open Electron app from build directory
|
||||
appElectron = await electron.launch({ args: ['dist/main/index.js'] })
|
||||
appElectron = await electron.launch({
|
||||
args: ['dist/main/index.js'],
|
||||
locale: 'en-US',
|
||||
colorScheme: 'light',
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
})
|
||||
appWindow = await appElectron.firstWindow()
|
||||
|
||||
await appWindow.waitForEvent('load')
|
||||
|
||||
+42
-39
@@ -1,6 +1,6 @@
|
||||
import { fileURLToPath } from 'url'
|
||||
import { defineConfig } from 'vite'
|
||||
import ElectronPlugin from 'vite-plugin-electron'
|
||||
import ElectronPlugin, { ElectronOptions } from 'vite-plugin-electron'
|
||||
import RendererPlugin from 'vite-plugin-electron-renderer'
|
||||
import EslintPlugin from 'vite-plugin-eslint'
|
||||
import VuetifyPlugin from 'vite-plugin-vuetify'
|
||||
@@ -15,6 +15,46 @@ const isDevEnv = process.env.NODE_ENV === 'development'
|
||||
export default defineConfig(() => {
|
||||
rmSync('dist', { recursive: true, force: true })
|
||||
|
||||
const electronPluginConfigs: ElectronOptions[] = [
|
||||
{
|
||||
entry: 'src/main/index.ts',
|
||||
onstart({ startup }) {
|
||||
startup()
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
assetsDir: '.',
|
||||
outDir: 'dist/main',
|
||||
rollupOptions: {
|
||||
external: ['electron', ...builtinModules]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: 'src/preload/index.ts',
|
||||
onstart({ reload }) {
|
||||
reload()
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
outDir: 'dist/preload'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
if (isDevEnv) {
|
||||
electronPluginConfigs.push({
|
||||
entry: 'src/main/index.dev.ts',
|
||||
vite: {
|
||||
build: {
|
||||
outDir: 'dist/main'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
define: {
|
||||
__VUE_I18N_FULL_INSTALL__: true,
|
||||
@@ -46,44 +86,7 @@ export default defineConfig(() => {
|
||||
// Docs: https://github.com/gxmari007/vite-plugin-eslint
|
||||
EslintPlugin(),
|
||||
// Docs: https://github.com/electron-vite/vite-plugin-electron
|
||||
ElectronPlugin([
|
||||
{
|
||||
entry: 'src/main/index.ts',
|
||||
onstart({ startup }) {
|
||||
startup()
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
assetsDir: '.',
|
||||
outDir: 'dist/main',
|
||||
rollupOptions: {
|
||||
external: ['electron', ...builtinModules]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
isDevEnv
|
||||
? {
|
||||
entry: 'src/main/index.dev.ts',
|
||||
vite: {
|
||||
build: {
|
||||
outDir: 'dist/main'
|
||||
}
|
||||
}
|
||||
}
|
||||
: {},
|
||||
{
|
||||
entry: 'src/preload/index.ts',
|
||||
onstart({ reload }) {
|
||||
reload()
|
||||
},
|
||||
vite: {
|
||||
build: {
|
||||
outDir: 'dist/preload'
|
||||
}
|
||||
}
|
||||
}
|
||||
]),
|
||||
ElectronPlugin(electronPluginConfigs),
|
||||
RendererPlugin()
|
||||
]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user