123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- 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)
|