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.
127 lines
3.5 KiB
127 lines
3.5 KiB
1 month ago
|
import { defineConfig, loadEnv } from 'vite';
|
||
|
import vue from '@vitejs/plugin-vue';
|
||
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||
|
import path from 'path';
|
||
|
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
||
|
import AutoImport from 'unplugin-auto-import/vite';
|
||
|
import Components from 'unplugin-vue-components/vite';
|
||
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
|
||
|
import gzipPlugin from 'rollup-plugin-gzip';
|
||
|
// import eslintPlugin from 'vite-plugin-eslint';
|
||
|
|
||
|
const pathSrc = path.resolve(__dirname, 'src');
|
||
|
const root = process.cwd();
|
||
|
// 开发
|
||
|
const apiTarget = 'http://gateway.product.dev.com:30115/';
|
||
|
const apiSluiceTarget = 'http://shuili-admin.product.dev.com:30115';
|
||
|
// const apiTarget = 'http://sy.datametatech.com:60006/';
|
||
|
// https://vitejs.dev/config/
|
||
|
export default defineConfig(({ mode }) => {
|
||
|
const env = loadEnv(mode, path.resolve(root, './env'));
|
||
|
return {
|
||
|
envDir: './env',
|
||
|
base: env.VITE_BASE_URL,
|
||
|
resolve: {
|
||
|
alias: {
|
||
|
'@': pathSrc,
|
||
|
'~/': `${pathSrc}/`
|
||
|
}
|
||
|
},
|
||
|
css: {
|
||
|
preprocessorOptions: {
|
||
|
scss: {
|
||
|
additionalData: `@use "~/theme/element/index.scss" as *;`
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
plugins: [
|
||
|
vue({
|
||
|
template: {
|
||
|
compilerOptions: {
|
||
|
isCustomElement: (tag) => tag.startsWith('iconpark-')
|
||
|
}
|
||
|
}
|
||
|
}),
|
||
|
vueJsx(),
|
||
|
AutoImport({
|
||
|
resolvers: [ElementPlusResolver()]
|
||
|
}),
|
||
|
Components({
|
||
|
// allow auto load markdown components under `./src/components/`
|
||
|
extensions: ['vue', 'md'],
|
||
|
// allow auto import and register components used in markdown
|
||
|
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
||
|
resolvers: [
|
||
|
ElementPlusResolver({
|
||
|
importStyle: 'sass'
|
||
|
})
|
||
|
],
|
||
|
dts: 'src/components.d.ts'
|
||
|
}),
|
||
|
viteStaticCopy({
|
||
|
targets: [
|
||
|
{
|
||
|
src: './node_modules/sy-cesium-sdk/dist/resources',
|
||
|
dest: ''
|
||
|
}
|
||
|
]
|
||
|
})
|
||
|
],
|
||
|
server: {
|
||
|
host: '0.0.0.0',
|
||
|
port: 6050,
|
||
|
proxy: {
|
||
|
|
||
|
'/proxy': {
|
||
|
target: apiTarget,
|
||
|
changeOrigin: true
|
||
|
},
|
||
|
'/iserver': {
|
||
|
target: 'http://172.16.34.41:8090',
|
||
|
changeOrigin: true
|
||
|
},
|
||
|
'/api/iserver': {
|
||
|
target: 'http://172.16.34.41:8090',
|
||
|
changeOrigin: true,
|
||
|
rewrite: (path) => path.replace(/^\/api\/iserver/, '/iserver')
|
||
|
},
|
||
|
'/api': {
|
||
|
target: 'http://shuili.product.dev.com:30115', // 'http://172.16.34.59:18083'
|
||
|
changeOrigin: true,
|
||
|
rewrite: (path) => path.replace(/^\/api/, '/tianhui-admin-web')
|
||
|
},
|
||
|
'/geoserver': {
|
||
|
target: 'http://172.16.32.77:8700',
|
||
|
changeOrigin: true
|
||
|
},
|
||
|
'/mapserver': {
|
||
|
target: 'http://172.16.34.71:8083/mapdata',
|
||
|
changeOrigin: true,
|
||
|
rewrite: (path) => path.replace(/^\/mapserver/, '')
|
||
|
},
|
||
|
'/images': {
|
||
|
target: apiTarget,
|
||
|
changeOrigin: true
|
||
|
},
|
||
|
'/objs': {
|
||
|
target: apiTarget,
|
||
|
changeOrigin: true
|
||
|
// rewrite: (path) => path.replace(/^\/sy-mixengine-ui/, '')
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
build: {
|
||
|
rollupOptions: {
|
||
|
output: {
|
||
|
manualChunks: {
|
||
|
sycim: ['sy-cesium-sdk'],
|
||
|
vue: ['vue']
|
||
|
}
|
||
|
},
|
||
|
plugins: [gzipPlugin()]
|
||
|
},
|
||
|
chunkSizeWarningLimit: 6000
|
||
|
}
|
||
|
} as any;
|
||
|
});
|