refactor(vite.config): centralized configs

This commit is contained in:
草鞋没号 committed 2021-11-09 10:17:06 +08:00
1 parent 446a161565
commit 01ceddaf00
5 files changed
+13 -13

No files matched your search

+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: join(__dirname, '../src/main'),
build: {
outDir: join(__dirname, '../dist/main'),
lib: {
entry: 'index.ts',
formats: ['cjs'],
},
sourcemap: false,
minify: false,
emptyOutDir: true,
rollupOptions: {
external: [
...builtinModules,
'electron',
],
output: {
entryFileNames: '[name].cjs',
},
},
},
})
+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: join(__dirname, '../src/preload'),
build: {
outDir: join(__dirname, '../dist/preload'),
lib: {
entry: 'index.ts',
formats: ['cjs'],
},
sourcemap: false,
minify: false,
emptyOutDir: true,
rollupOptions: {
external: [
...builtinModules,
'electron',
],
output: {
entryFileNames: '[name].cjs',
},
},
},
})
+20
View File
@@ -0,0 +1,20 @@
import { join } from 'path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import pkg from '../package.json'
// https://vitejs.dev/config/
export default defineConfig({
root: join(__dirname, '../src/react-ts'),
plugins: [react()],
base: './',
build: {
emptyOutDir: true,
minify: false,
outDir: join(__dirname, '../dist/react-ts'),
},
server: {
host: pkg.env.HOST,
port: pkg.env.PORT,
},
})