blossom/blossom-editor/electron.vite.config.ts

72 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-08-07 11:50:22 +08:00
import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
2023-08-11 00:59:36 +08:00
import { visualizer } from 'rollup-plugin-visualizer'
2023-08-07 11:50:22 +08:00
2023-08-11 01:12:17 +08:00
// 为 Element Plus 按需引入样式。
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
2023-08-07 11:50:22 +08:00
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()]
},
preload: {
plugins: [externalizeDepsPlugin()]
},
renderer: {
2023-11-28 01:56:16 +08:00
envDir: resolve('src/env'),
server: {
host: '0.0.0.0',
port: 5173,
hmr: true
},
2023-08-11 00:59:36 +08:00
plugins: [
vue(),
visualizer({
emitFile: false,
2023-11-28 01:56:16 +08:00
filename: 'stats.html'
2023-08-11 01:12:17 +08:00
}),
// ElementPlus 按需引入的插件
AutoImport({
2023-11-28 01:56:16 +08:00
resolvers: [ElementPlusResolver()]
2023-08-11 01:12:17 +08:00
}),
Components({
2023-11-28 01:56:16 +08:00
resolvers: [ElementPlusResolver()]
2023-08-11 00:59:36 +08:00
})
],
2023-08-07 11:50:22 +08:00
resolve: {
alias: {
'@renderer': resolve('src/renderer/src')
}
},
css: {
preprocessorOptions: {
scss: {
/**
* 使
* '@import "@/assets/scss/globalVariable1.scss";@import"@/assets/scss/globalVariable2.scss";'
*/
2023-11-28 01:56:16 +08:00
additionalData: '@import "@renderer/assets/styles/config.scss";'
2023-08-07 11:50:22 +08:00
}
}
},
2023-08-11 00:59:36 +08:00
// electorn 应用不需要拆分文件打包
2023-10-08 11:33:00 +08:00
build: {
// 警告大小, 单位kb
// chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
//@ts-ignore
manualChunks(id) {
if (id.includes('node_modules')) {
2023-11-28 01:56:16 +08:00
return id.toString().split('node_modules/')[1].split('/')[0].toString()
2023-10-08 11:33:00 +08:00
}
}
}
}
}
2023-08-07 11:50:22 +08:00
}
})