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

89 lines
2.4 KiB

import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { defineConfig, loadEnv, UserConfig, UserConfigExport } from 'vite';
import eslint from 'vite-plugin-eslint';
import html from 'vite-plugin-html';
import tsconfigPaths from 'vite-tsconfig-paths';
import viteSvgIcons from 'vite-plugin-svg-icons';
const prefix = `monaco-editor/esm/vs`;
export default (config: UserConfig): UserConfigExport => {
const mode = config.mode as string;
return defineConfig({
base: './',
compilerOptions: {
isCustomElement: (tag) => tag.startsWith('easy-'),
},
optimizeDeps: {
include: [
`${prefix}/language/json/json.worker`,
`${prefix}/language/css/css.worker`,
`${prefix}/language/html/html.worker`,
`${prefix}/language/typescript/ts.worker`,
`${prefix}/editor/editor.worker`,
],
},
plugins: [
vue(),
html({
inject: {
injectData: {
apiURL: loadEnv(mode, process.cwd()).VITE_APP_API,
socketURL: loadEnv(mode, process.cwd()).VITE_APP_SOCKET,
title: '',
},
},
minify: true,
}),
tsconfigPaths(),
eslint({
cache: false,
fix: false,
include: ['src/**/*.ts', 'src/**/*.vue'],
}),
viteSvgIcons({
iconDirs: [resolve(__dirname, 'src/assets/icons/svg')],
symbolId: 'icon-[dir]-[name]',
}),
],
build: {
chunkSizeWarningLimit: 1024,
rollupOptions: {
output: {
manualChunks: {
monacoeditor: ['monaco-editor'],
quill: ['quill'],
lodash: ['lodash'],
lib: ['sortablejs', 'vxe-table', 'xe-utils'],
vlib: ['vue', 'vue-router', 'vuex', 'vue-i18n', 'element-plus'],
},
},
},
},
resolve: {
alias: {
// 配置别名
'@': resolve(__dirname, './src'),
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
},
},
server: {
open: true, // 自动启动浏览器
host: '0.0.0.0', // localhost
port: 8001, // 端口号
https: false,
// 接口代理
proxy: {
'/thing/': {
// 远程请求 代理到后端服务端口
target: "http://192.168.8.108:2020/",
changeOrigin: true // 允许跨域
},
'/thing/websocket': {
target: 'ws://192.168.8.101:81/',
ws: true,
},
},
},
});
};