1 Star 0 Fork 0

期颐/electron-music

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
期颐 提交于 2022-11-11 15:05 . first commit
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
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/iyuanlu/electron-music.git
git@gitee.com:iyuanlu/electron-music.git
iyuanlu
electron-music
electron-music
master

搜索帮助