123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import topLevelAwait from 'vite-plugin-top-level-await'
- import { resolve } from 'path'
- import viteCompression from 'vite-plugin-compression';//Gzip
- import { visualizer } from "rollup-plugin-visualizer";
- import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' // 【svg-icons相关】
- import VitePluginHtmlEnv from 'vite-plugin-html-env'
- const time = new Date().getTime()
- // @ts-ignore
- // https://vitejs.dev/config/
- export default defineConfig({
- define: {
- 'process.env': process.env
- },
- plugins: [vue(), viteCompression(), VitePluginHtmlEnv(), visualizer(), createSvgIconsPlugin({
- // 指定需要缓存的图标文件夹
- iconDirs: [resolve(process.cwd(), 'src/assets/svg/global'), resolve(process.cwd(), 'src/assets/svg/business')],
- // 指定symbolId格式
- symbolId: 'icon-[dir]-[name]',
- }), topLevelAwait({
- promiseExportName: '__tla',
- promiseImportName: i => `__tla_${i}`
- })],
- base: '/',
- resolve: {
- alias: {
- '@': resolve(__dirname, 'src'),
- '~@': resolve(__dirname, 'src'),
- '@views': resolve(__dirname, 'src/views'),
- '@components': resolve(__dirname, 'src/components')
- },
- },
- esbuild: {
- jsxFactory: 'h',
- jsxFragment: 'Fragment',
- jsxInject: "import { h } from 'vue';"
- },
- server: {
- port: 6969,
- // open: true,
- https: false,
- host: '0.0.0.0',
- strictPort: false,
- proxy: {
- '/BaseMap1-api/': {
- // target: 'http://59.255.48.160:81/',
- target: 'http://127.0.0.1:3999/',
- changeOrigin: true,
- rewrite: path => {
- return path.replace(/^\/BaseMap1-api/, '')
- }
- },
- '/BaseMap2-api/': {
- // target: 'http://59.212.37.22/',
- target: 'http://127.0.0.1:3998/',
- changeOrigin: true,
- rewrite: path => {
- return path.replace(/^\/BaseMap2-api/, '')
- }
- },
- '/BaseMap3-api/': {
- // target: 'http://59.212.146.170/',
- target: 'http://127.0.0.1:3997/',
- changeOrigin: true,
- rewrite: path => {
- return path.replace(/^\/BaseMap3-api/, '')
- }
- },
- '/business-api/': {
- // target: 'http://192.168.31.26:7074/',
- target: 'http://8.140.240.182:18087/',
- changeOrigin: true,
- rewrite: path => {
- return path.replace(/^\/business-api/, '')
- }
- },
- }
- },
- build: {
- outDir: "gis-web",
- rollupOptions: {//分包优化
- output: {
- manualChunks(id) {
- if (id.includes('node_modules')) {
- return time + id.toString().split('node_modules/')[1].split('/')[0].toString();
- } else {
- return time + id.toString();
- }
- // if(id.indexOf('node_modules') > -1) {
- // return 'vendor'
- // }
- }
- }
- }
- },
- publicDir: 'src/out',
- optimizeDeps: {
- include: []
- }
- })
|