import { defineConfig } from 'vite' // import vue from '@vitejs/plugin-vue' import legacy from '@vitejs/plugin-legacy' import vue from '@vitejs/plugin-vue2' import vueJsx from '@vitejs/plugin-vue2-jsx' import { createSvgIconsPlugin } from "vite-plugin-svg-icons"; import { viteStaticCopy } from 'vite-plugin-static-copy' import path from 'path' const resolve = path.resolve const baseApi = 'http://llm.yangzhiqiang.tech/' const config = { base: '/openui', build: { rollupOptions: { input: { main: resolve(__dirname, 'index.html'), // mobile: resolve(__dirname, 'mobile.html'), }, // output:{ // manualChunks:{ // 'pdfjs':['pdfjs-dist'], // 'axios':['axios'], // 'ui':['element-ui'], // 'markdown':['markdown-it-vue'], // // 'clipboard.js ':['clipboard.js'] // } // } }, }, server: { port: 5173, host: '0.0.0.0', proxy: { '/api': { target: baseApi, changeOrigin: true, pathRewrite: { '^/api': 'api' } }, '/auth': { target: baseApi, changeOrigin: true, pathRewrite: { '^/auth': 'auth' } } } }, resolve: { alias: Object.entries({ '@common': path.join(__dirname, 'src/common/'), '@pc': path.join(__dirname, 'src/pc/'), '@mobile': path.join(__dirname, 'src/mobile/'), '@': path.join(__dirname), }).map(([k, v]) => ({ find: k, replacement: v })) }, plugins: [ vue(), vueJsx(), createSvgIconsPlugin({ iconDirs: [path.join(__dirname, "src/common/assets/svgIcons")], // svg文件位置 symbolId: "icon-[dir]-[name]" }), viteStaticCopy({ targets: [ { src: 'node_modules/pdfjs-dist/cmaps', dest: '' } ] }) ], } if (!process.env.IS_MODERN) { config.plugins.push( legacy({ targets: ['defaults', 'ie >= 11', 'chrome 52'], //需要兼容的目标列表,可以设置多个 additionalLegacyPolyfills: ['regenerator-runtime/runtime'], renderLegacyChunks: true, polyfills: [ 'es.symbol', 'es.array.filter', 'es.promise', 'es.promise.finally', 'es/map', 'es/set', 'es.array.for-each', 'es.object.define-properties', 'es.object.define-property', 'es.object.get-own-property-descriptor', 'es.object.get-own-property-descriptors', 'es.object.keys', 'es.object.to-string', 'web.dom-collections.for-each', 'esnext.global-this', 'esnext.string.match-all' ] }) ) } // https://vitejs.dev/config/ export default defineConfig(config)