You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.2 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { defineConfig } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import vue from '@vitejs/plugin-vue'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import commonjs from '@rollup/plugin-commonjs';
import legacy from '@vitejs/plugin-legacy';
const path = require('path');
export default defineConfig({
// 起个别名,在引用资源时,可以用‘@/资源路径’直接访问
resolve: {
// https://cn.vitejs.dev/config/#resolve-alias
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
// https://cn.vitejs.dev/config/#resolve-extensions
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
plugins: [
commonjs(),
vue(),
legacy({
targets:["defaults","not IE 11"],
}),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹(路径为存放所有svg图标的文件夹不单个svg图标)
iconDirs: [path.resolve(process.cwd(), 'src/icons/svg')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]'
})
],
optimizeDeps: {
include: ['@/components/vform/designer.umd.js'] //此处路径必须跟main.js中import路径完全一致
},
build: {
sourcemap: false,
minify: 'terser',
chunkSizeWarningLimit: 2500,
emptyOutDir: true,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
},
chunkFileNames: (chunkInfo) => {
const facadeModuleId = chunkInfo.facadeModuleId ? chunkInfo.facadeModuleId.split('/') : [];
const fileName = facadeModuleId[facadeModuleId.length - 2] || '[name]';
return `js/${fileName}/[name].[hash].js`;
}
}
}
},
// 配置前端服务地址和端口
server: {
host: '0.0.0.0',
port: 3000,
// 是否开启 https
https: true,
proxy: {
'/security-api': {
// 后台地址
target: 'http://192.168.3.8:8002',
changeOrigin: true,
rewrite: path => path.replace(/^\/security-api/, '')
},
'/admin-api': {
// 后台地址
target: 'http://192.168.3.8:8003',
changeOrigin: true,
rewrite: path => path.replace(/^\/admin-api/, '')
},
'/plant-api': {
// 后台地址
target: 'https://192.168.3.8:8000',
changeOrigin: true,
secure: false,
rewrite: path => path.replace(/^\/plant-api/, '')
},
'/flow-api': {
target: 'http://192.168.3.8:8091',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/flow-api/, '')
},
// '/wss-api': {
// target: 'wss://192.168.3.8:8000',
// secure: false,
// ws: true,
// rewrite: (p) => p.replace(/^\/wss-api/, '')
// }
}
}
})