Files
test-project-161/vite.config.ts
T
Song e803167b31 refactor: upgrade deps, setup tailwind4 and correct ci (#258)
* refresh

* e2e test

* Change debugger type from 'pwa-chrome' to 'chrome'

* ci: align workflows with electron-vite-vue#540

* chore: update test, tsconfig and deps

* chore: update deps and debug config

* chore: refresh style

* docs: update readme

* docs: make linter happy

* ci: bump versions

* chore: refactor update handling and improve UI elements

* 1.0.0
2026-05-31 22:42:38 +08:00

69 lines
1.9 KiB
TypeScript

import { rmSync } from 'node:fs'
import path from 'node:path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { electronSimple } from 'vite-plugin-electron/multi-env'
import { notBundle } from 'vite-plugin-electron/plugin'
import pkg from './package.json'
const external = Object.keys(
'dependencies' in pkg ? (pkg.dependencies as Record<string, string>) : {},
)
// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
rmSync('dist-electron', { recursive: true, force: true })
const isServe = command === 'serve'
const isBuild = command === 'build'
const sourcemap = isServe || !!process.env.VSCODE_DEBUG
return {
resolve: {
alias: {
'@': path.join(__dirname, 'src'),
},
},
plugins: [
react(),
tailwindcss(),
electronSimple({
main: {
input: 'electron/main/index.ts',
plugins: [notBundle()],
options: {
build: {
sourcemap,
minify: isBuild,
outDir: 'dist-electron/main',
rolldownOptions: {
external,
},
},
},
},
preload: {
input: 'electron/preload/index.ts',
plugins: [notBundle()],
options: {
build: {
sourcemap: sourcemap ? 'inline' : undefined, // #332
minify: isBuild,
outDir: 'dist-electron/preload',
rolldownOptions: {
external,
},
},
},
},
// Polyfill the Electron and Node.js API for Renderer process.
// If you want use Node.js in Renderer process, the `nodeIntegration` needs to be enabled in the Main process.
// See 👉 https://github.com/electron-vite/vite-plugin-electron-renderer
// renderer: {},
}),
],
clearScreen: false,
}
})