refactor(structure): src directory

This commit is contained in:
草鞋没号 committed 2021-11-08 19:17:39 +08:00
1 parent 2273453449
commit 2dd8f3bf5a
23 files changed
+103 -86

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { join } from 'path'
import { app, BrowserWindow } from 'electron'
let win: BrowserWindow | null = null
async function mainWin() {
win = new BrowserWindow({
title: 'Main window',
webPreferences: {
preload: join(__dirname, '../preload/index.cjs')
},
})
if (app.isPackaged) {
win.loadFile(join(__dirname, '../react-ts/index.html'))
} else {
const pkg = await import('../../package.json')
const url = `http://${pkg.env.HOST || '127.0.0.1'}:${pkg.env.PORT}`
win.loadURL(url)
win.maximize()
}
}
app.whenReady().then(mainWin)
app.on('window-all-closed', () => {
win = null
app.quit()
})
+27
View File
@@ -0,0 +1,27 @@
import { join } from 'path'
import { builtinModules } from 'module'
import { defineConfig } from 'vite'
export default defineConfig({
mode: process.env.NODE_ENV,
root: __dirname,
build: {
outDir: join(process.cwd(), 'dist/main'),
lib: {
entry: 'index.ts',
formats: ['cjs'],
},
sourcemap: false,
minify: false,
emptyOutDir: true,
rollupOptions: {
external: [
...builtinModules,
'electron',
],
output: {
entryFileNames: '[name].cjs',
},
},
},
})