12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import UnoCSS from 'unocss/vite'
- import { resolve } from 'path'
- import config from './src/config'
- // https://vitejs.dev/config/
- export default defineConfig({
- css: {
- extract: true,
- },
- resolve: {
- alias: {
- '~src': resolve(__dirname, './src'),
- '~ass': resolve(__dirname, './src/assets'),
- '~com': resolve(__dirname, './src/components'),
- '~api': resolve(__dirname, './src/api/modules'),
- '~sto': resolve(__dirname, './src/store/modules'),
- '~uti': resolve(__dirname, './src/utils'),
- },
- },
- plugins: [
- vue(),
- UnoCSS(),
- ],
- build: {
- target: 'esnext', // 设置构建目标
- minify: 'esbuild', // 使用 esbuild 进行压缩
- chunkSizeWarningLimit: 1000, // 将警告的阈值提高到 1000 KB
- rollupOptions: {
- output: {
- manualChunks(id) {
- let libStr = '@vue,hc-vue3-ui,element-plus,z-element-plus,echarts,vue-router,pinia,vuedraggable,js-web-screen-shot,js-fast-way,nprogress,pinyin-pro'
- const libs = libStr.split(',')
- if (id.includes('node_modules')) {
- const arr = id.toString().split('node_modules/')[1].split('/')
- if (libs.indexOf(arr[0]) !== -1) {
- return '_' + arr[0]
- } else {
- return '__vendor'
- }
- }
- },
- chunkFileNames: 'static/js1/[name]-[hash].js',
- entryFileNames: 'static/js2/[name]-[hash].js',
- assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
- },
- },
- },
- server: {
- ...config.vite,
- proxy: {
- '/api': {
- ws: true,
- changeOrigin: true,
- target: config.target,
- rewrite: (path) => path.replace(new RegExp('^/api'), '/'),
- },
- },
- },
- })
|