refactor: use vite alternative rollup

This commit is contained in:
草鞋没号
2021-11-11 17:52:50 +08:00
parent be6e33c148
commit b4fc358318
37 changed files with 555 additions and 1187 deletions

View File

@@ -0,0 +1,41 @@
/**
* @type {import('electron-builder').Configuration}
*/
const config = {
appId: "308487730@qq.com",
asar: true,
directories: {
output: "release/${version}"
},
files: [
"!node_modules",
"dist",
"package.json"
],
mac: {
artifactName: "${productName}_${version}.${ext}",
target: [
"dmg"
]
},
win: {
target: [
{
target: "nsis",
arch: [
"x64"
]
}
],
artifactName: "${productName}_${version}.${ext}"
},
nsis: {
oneClick: false,
perMachine: false,
allowToChangeInstallationDirectory: true,
deleteAppDataOnUninstall: false
}
}
export { config }

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: join(__dirname, '../src/main'),
build: {
outDir: '../../dist/main',
lib: {
entry: 'index.ts',
formats: ['cjs'],
},
sourcemap: false,
minify: false,
emptyOutDir: true,
rollupOptions: {
external: [
...builtinModules,
'electron',
],
output: {
entryFileNames: '[name].cjs',
},
},
},
})

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: join(__dirname, '../src/preload'),
build: {
outDir: '../../dist/preload',
lib: {
entry: 'index.ts',
formats: ['cjs'],
},
sourcemap: false,
minify: false,
emptyOutDir: true,
rollupOptions: {
external: [
...builtinModules,
'electron',
],
output: {
entryFileNames: '[name].cjs',
},
},
},
})

View File

@@ -0,0 +1,20 @@
import { join } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pkg from '../package.json'
// https://vitejs.dev/config/
export default defineConfig({
root: join(__dirname, '../src/renderer'),
plugins: [vue()],
base: './',
build: {
emptyOutDir: true,
minify: false,
outDir: '../../dist/renderer',
},
server: {
host: pkg.env.HOST,
port: pkg.env.PORT,
},
})