refactor: refactor
This commit is contained in:
@@ -1,31 +1,34 @@
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import path from 'path'
|
||||
|
||||
import { wrapperEnv, createProxy } from './build/utils'
|
||||
import { convertEnv, getSrcPath, getRootPath } from './build/utils'
|
||||
import { createViteProxy, viteDefine } from './build/config'
|
||||
import { createVitePlugins } from './build/plugin'
|
||||
import { OUTPUT_DIR } from './build/constant'
|
||||
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
const root = process.cwd()
|
||||
const srcPath = getSrcPath()
|
||||
const rootPath = getRootPath()
|
||||
const isBuild = command === 'build'
|
||||
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
const viteEnv = wrapperEnv(env)
|
||||
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY } = viteEnv
|
||||
const viteEnv = convertEnv(env)
|
||||
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_USE_PROXY, VITE_PROXY_TYPE } = viteEnv
|
||||
|
||||
return {
|
||||
root,
|
||||
base: VITE_PUBLIC_PATH || '/',
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, 'src'),
|
||||
'~': rootPath,
|
||||
'@': srcPath,
|
||||
},
|
||||
},
|
||||
define: viteDefine,
|
||||
plugins: createVitePlugins(viteEnv, isBuild),
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: VITE_PORT,
|
||||
proxy: createProxy(VITE_PROXY),
|
||||
open: false,
|
||||
proxy: createViteProxy(VITE_USE_PROXY, VITE_PROXY_TYPE),
|
||||
},
|
||||
build: {
|
||||
target: 'es2015',
|
||||
|
||||
Reference in New Issue
Block a user