基础环境
- vite版本:4+
- 项目框架:vue 3
- UI框架:Ant-Design-Vue
- 开发语言:TypeScript
import { fileURLToPath, URL } from 'node:url'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { defineConfig, loadEnv } from 'vite'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
const pathResolve = (dir: string): string => {
return resolve(__dirname, '.', dir)
}
export default defineConfig((command: any, mode: string) => {
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [
vue(),
vueJsx(),
Components({
resolvers: [AntDesignVueResolver({ importStyle: 'less' })]
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
base: '/evalweb/',
server: {
https: false,
port: 8000,
host: '0.0.0.0',
proxy: {}
},
build: {
outDir: 'evalweb',
sourcemap: false,
chunkSizeWarningLimit: 1500,
assetsInlineLimit: 1024 * 5,
modulePreload: {
polyfill: true
},
cssCodeSplit: true,
rollupOptions: {
input: {
index: pathResolve('index.html')
},
output: {
chunkFileNames: 'static/js/[name]-[hash:10].js',
entryFileNames: 'static/js/[name]-[hash:10].js',
assetFileNames: 'static/[ext]/[name]-[hash:10].[ext]'
}
}
},
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: `true; @import '@/style/ant-design.less'; @import '@/style/canon-color.less'; @import '@/style/mixin.less';`
},
javascriptEnabled: true
}
}
}
}
})