import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import legacyPlugin from 'vite-plugin-legacy' const path = require('path') console.log(__dirname); function resolve_path (dir) { return path.join(__dirname, './', dir) } export default defineConfig({ plugins: [ vue(), // The default options are listed below. Pass nothing to use them. legacyPlugin({ // The browsers that must be supported by your legacy bundle. // https://babeljs.io/docs/en/babel-preset-env#targets targets: [ 'ie >= 11' ], // Define which polyfills your legacy bundle needs. They will be loaded // from the Polyfill.io server. See the "Polyfills" section for more info. polyfills: [ // Empty by default ], // Toggles whether or not browserslist config sources are used. // https://babeljs.io/docs/en/babel-preset-env#ignorebrowserslistconfig ignoreBrowserslistConfig: false, // When true, core-js@3 modules are inlined based on usage. // When false, global namespace APIs (eg: Object.entries) are loaded // from the Polyfill.io server. corejs: false, }) ], base:'./', clearScreen:false, resolve:{ alias:{ '@':resolve_path('src'), } }, css:{ devSourcemap:true }, server:{ proxy:{ '/shzl/api': { target: 'https://sjgl.wodcloud.com/shzl/api', // 接口域名 changeOrigin: true, // 是否跨域 rewrite: (path) => path.replace('/shzl/api', ''), secure: false,//解决证书缺失问题 }, '/apaas':{ target: 'https://www.gzdex.com.cn/apaas/', // 所要代理的目标地址 rewrite: path => path.replace('/apaas', ''), // 重写传过来的path路径,比如 `/api/index/1?id=10&name=zs`(注意:path路径最前面有斜杠(/),因此,正则匹配的时候不要忘了是斜杠(/)开头的;选项的 key 也是斜杠(/)开头的) changeOrigin: true, // true/false, Default: false - changes the origin of the host header to the target URL secure: false,//解决证书缺失问题 } } }, build:{ outDir:'dist/zjhl', assetsDir:'static' }, })