代码拉取完成,页面将自动刷新
import type { ConfigEnv, UserConfig } from 'vite'
import { loadEnv } from 'vite'
import { createProxy } from './build/vite/proxy'
import { createVitePlugins } from './build/vite/plugin'
import { wrapperEnv } from './build/utils'
// need install plugin @typings/node
import { resolve } from 'path'
function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir)
}
export default ({ command, mode }: ConfigEnv): UserConfig => {
const root = process.cwd()
const env = loadEnv(mode, root)
// this function can be converted to different typings
const viteEnv = wrapperEnv(env)
const { VITE_PORT, VITE_PROXY, VITE_DROP_CONSOLE } = viteEnv
const isBuild = command === 'build'
return {
base: './',
server: {
// Listening on all local ips
host: true,
open: true,
port: VITE_PORT,
// Load proxy configuration from .env
proxy: createProxy(VITE_PROXY)
},
// the project uses lots of vite plugins, so they are extracted and managed separately
plugins: createVitePlugins(isBuild),
build: {
target: 'es2015',
cssTarget: 'chrome86',
minify: 'terser',
terserOptions: {
compress: {
keep_infinity: true,
// used to delete console and debugger in production environment
drop_console: VITE_DROP_CONSOLE
}
},
chunkSizeWarningLimit: 2000
},
css: {
preprocessorOptions: {
less: {
charset: false,
additionalData: `@import "${resolve('src/design/variable/index.less')}";`,
javascriptEnabled: true
}
}
},
resolve: {
alias: [
{
find: /@\//,
replacement: pathResolve('src') + '/'
}
]
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。