代码拉取完成,页面将自动刷新
import { rmSync } from 'fs'
// @ts-ignore
import path from 'path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import electron from 'vite-electron-plugin'
import { customStart } from 'vite-electron-plugin/plugin'
import renderer from 'vite-plugin-electron-renderer'
// @ts-ignore
import pkg from './package.json'
import vitePluginImp from 'vite-plugin-imp';
rmSync(path.join(__dirname, 'dist-electron'), { recursive: true, force: true })
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': path.join(__dirname, 'src'),
'styles': path.join(__dirname, 'src/assets/styles'),
},
},
plugins: [
react(),
electron({
include: [
'electron',
'preload',
],
transformOptions: {
sourcemap: !!process.env.VSCODE_DEBUG,
},
// Will start Electron via VSCode Debug
plugins: process.env.VSCODE_DEBUG
? [customStart(debounce(() => console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')))]
: undefined,
}),
renderer({
nodeIntegration: true,
}),
vitePluginImp({
libList: [
{
libName: 'antd',
style: () => false,
libDirectory: 'es',
replaceOldImport: true,
},
],
}),
],
server: process.env.VSCODE_DEBUG ? (() => {
const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
return {
host: url.hostname,
port: +url.port,
}
})() : undefined,
clearScreen: false,
css: {
// css预处理器
preprocessorOptions: {
less: {
additionalData: '@import "./src/assets/css/variable.less";',
// modifyVars: {
// 'primary-color': '#2c2c2c',
// 'link-color': '#1DA57A',
// 'border-radius-base': '2px',
// },
javascriptEnabled: true
},
},
},
})
function debounce<Fn extends (...args: any[]) => void>(fn: Fn, delay = 299) {
let t: NodeJS.Timeout
return ((...args) => {
clearTimeout(t)
t = setTimeout(() => fn(...args), delay)
}) as Fn
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。