Skip to content

Commit

Permalink
build: 🔨 提高开发环境的编译速度
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Oct 17, 2023
1 parent d7361b4 commit 554d7ae
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { resolve } from 'node:path'
import { defineConfig, mergeConfig } from 'vite'
import useElectron from 'vite-plugin-electron'
import useRenderer from 'vite-plugin-electron-renderer'
import { notBundle } from 'vite-plugin-electron/plugin'

import useVue from '@vitejs/plugin-vue'
import useEslint from 'vite-plugin-eslint'
import useUnoCSS from 'unocss/vite'
import useSvg from 'vite-svg-loader'

const merge = config =>
const merge = (config, { command = '' } = {}) =>
mergeConfig(
{
resolve: {
Expand All @@ -17,38 +18,39 @@ const merge = config =>
'@electron': resolve('electron'),
},
},
plugins: [],
plugins: [...(command === 'serve' ? [notBundle()] : [])],
},
config,
)

// https://vitejs.dev/config/
export default merge(
defineConfig({
resolve: {
alias: {
'@': resolve('src'),
},
},
plugins: [
useEslint(),
useUnoCSS(),
useSvg(),
useVue(),
useElectron([
{
entry: 'electron/main.js',
vite: merge({}),
export default params =>
merge(
defineConfig({
resolve: {
alias: {
'@': resolve('src'),
},
{
entry: 'electron/preload.js',
onstart(args) {
args.reload()
},
plugins: [
useEslint(),
useUnoCSS(),
useSvg(),
useVue(),
useElectron([
{
entry: 'electron/main.js',
vite: merge({}, params),
},
vite: merge({}),
},
]),
useRenderer(),
],
}),
)
{
entry: 'electron/preload.js',
onstart(args) {
args.reload()
},
vite: merge({}, params),
},
]),
useRenderer(),
],
}),
)

0 comments on commit 554d7ae

Please sign in to comment.