YesPlayMusic/packages/main/vite.config.ts

40 lines
979 B
TypeScript
Raw Normal View History

2022-03-13 14:40:38 +08:00
import dotenv from 'dotenv'
import { builtinModules } from 'module'
import path from 'path'
2022-03-17 14:45:04 +08:00
import { visualizer } from 'rollup-plugin-visualizer'
2022-03-13 14:40:38 +08:00
import { defineConfig } from 'vite'
import pkg from '../../package.json'
dotenv.config({
path: path.resolve(process.cwd(), '.env'),
})
export default defineConfig({
root: __dirname,
build: {
outDir: '../../dist/main',
emptyOutDir: true,
lib: {
entry: 'index.ts',
formats: ['cjs'],
fileName: () => '[name].cjs',
},
minify: process.env./* from mode option */ NODE_ENV === 'production',
sourcemap: process.env./* from mode option */ NODE_ENV === 'debug',
rollupOptions: {
external: [
'electron',
...builtinModules,
...Object.keys(pkg.dependencies || {}),
],
2022-03-17 14:45:04 +08:00
plugins: [
visualizer({
filename: './bundle-stats-main.html',
gzipSize: true,
projectRoot: 'packages/main',
}),
],
2022-03-13 14:40:38 +08:00
},
},
})