57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
/**
|
|
* 项目配置文件vite.config.js
|
|
* @author andy
|
|
*/
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import electron from 'vite-plugin-electron'
|
|
import { resolve } from 'node:path'
|
|
import { parseEnv } from './src/utils/env'
|
|
export default defineConfig(({ command, mode }) => {
|
|
const viteEnv = loadEnv(mode, process.cwd())
|
|
const env = parseEnv(viteEnv)
|
|
|
|
return {
|
|
define: {
|
|
'process.env': env,
|
|
},
|
|
|
|
plugins: [
|
|
vue({
|
|
template: {
|
|
compilerOptions: {
|
|
// fix修复[Vue warn]: Failed to resolve component: swiper-container
|
|
isCustomElement: tag => tag.includes('swiper')
|
|
}
|
|
}
|
|
}),
|
|
electron({
|
|
entry: 'electron/main.js'
|
|
})
|
|
],
|
|
|
|
build: {
|
|
|
|
},
|
|
|
|
esbuild: {
|
|
// 是否删除生产环境console和debugger
|
|
drop: env['VITE_DROP_CONSOLE'] && command === 'build' ? ['console', 'debugger'] : []
|
|
},
|
|
|
|
server: {
|
|
port: env['VITE_PORT'],
|
|
proxy: {}
|
|
},
|
|
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, 'src'),
|
|
'@assets': resolve(__dirname, 'src/assets'),
|
|
'@components': resolve(__dirname, 'src/components'),
|
|
'@views': resolve(__dirname, 'src/views'),
|
|
}
|
|
}
|
|
}
|
|
})
|