first commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { resolve } from 'path'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
|
||||
import { convertEnv, getSrcPath, getRootPath } from './build/utils'
|
||||
import { viteDefine } from './build/config'
|
||||
import { OUTPUT_DIR, PROXY_CONFIG } from './build/constant'
|
||||
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
const srcPath = getSrcPath()
|
||||
const rootPath = getRootPath()
|
||||
const isBuild = command === 'build'
|
||||
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
const viteEnv = convertEnv(env)
|
||||
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_USE_PROXY, VITE_BASE_API } = viteEnv
|
||||
|
||||
return {
|
||||
base: VITE_PUBLIC_PATH || '/',
|
||||
resolve: {
|
||||
alias: {
|
||||
'~': rootPath,
|
||||
'@': srcPath,
|
||||
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
|
||||
}
|
||||
},
|
||||
define: viteDefine,
|
||||
plugins: [
|
||||
vue(),
|
||||
createSvgIconsPlugin({
|
||||
iconDirs: [resolve(__dirname, 'src/icons/svg')],
|
||||
symbolId: 'icon-[dir]-[name]'
|
||||
})
|
||||
],
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: VITE_PORT,
|
||||
open: true,
|
||||
proxy: VITE_USE_PROXY
|
||||
? {
|
||||
[VITE_BASE_API]: PROXY_CONFIG[VITE_BASE_API]
|
||||
}
|
||||
: undefined
|
||||
},
|
||||
build: {
|
||||
target: 'es2015',
|
||||
outDir: OUTPUT_DIR || 'dist',
|
||||
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
|
||||
chunkSizeWarningLimit: 1024 // chunk 大小警告的限制(单位kb)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user