2021-11-11 17:52:50 +08:00
|
|
|
import { join } from 'path'
|
|
|
|
import { builtinModules } from 'module'
|
|
|
|
import { defineConfig } from 'vite'
|
2022-01-05 09:09:16 +08:00
|
|
|
import pkg from '../package.json'
|
2021-11-11 17:52:50 +08:00
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
mode: process.env.NODE_ENV,
|
|
|
|
root: join(__dirname, '../src/preload'),
|
|
|
|
build: {
|
|
|
|
outDir: '../../dist/preload',
|
|
|
|
lib: {
|
|
|
|
entry: 'index.ts',
|
|
|
|
formats: ['cjs'],
|
|
|
|
},
|
2021-12-21 09:00:59 +08:00
|
|
|
minify: process.env.NODE_ENV === 'production',
|
2021-11-11 17:52:50 +08:00
|
|
|
emptyOutDir: true,
|
|
|
|
rollupOptions: {
|
|
|
|
external: [
|
|
|
|
'electron',
|
2022-01-05 09:09:16 +08:00
|
|
|
...builtinModules,
|
|
|
|
...Object.keys((pkg as Record<string, any>).dependencies || {}),
|
2021-11-11 17:52:50 +08:00
|
|
|
],
|
|
|
|
output: {
|
|
|
|
entryFileNames: '[name].cjs',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|