| | |
| | | import PkgConfig from 'vite-plugin-package-config' |
| | | import viteSvgIcons from 'vite-plugin-svg-icons' |
| | | import { viteVConsole } from 'vite-plugin-vconsole' |
| | | |
| | | import cesium from 'vite-plugin-cesium' |
| | | // autoImport |
| | | import AutoImport from 'unplugin-auto-import/vite' |
| | | import { CURRENT_CONFIG } from './src/api/http/config' |
| | | // https://vitejs.dev/config/ |
| | | export default ({ command, mode }: ConfigEnv): UserConfigExport => defineConfig({ |
| | | plugins: [ |
| | | vue(), |
| | | cesium(), |
| | | eslintPlugin({ |
| | | fix: true |
| | | }), |
| | |
| | | }), |
| | | viteVConsole({ |
| | | entry: path.resolve(__dirname, './src/main.ts'), // 入口文件 |
| | | // localEnabled: command === 'serve', // serve开发环境下 |
| | | localEnabled: command === 'serve', // serve开发环境下 |
| | | // enabled: command !== 'serve' || mode === 'test', // 打包环境下/发布测试包, |
| | | config: { // vconsole 配置项 |
| | | maxLogNumber: 1000, |
| | | theme: 'light' |
| | | } |
| | | }), |
| | | AutoImport({ |
| | | dts: 'types/auto-imports.d.ts', |
| | | imports: ['vue', 'vue-router'], |
| | | // 解决eslint报错问题 |
| | | eslintrc: { |
| | | // 这里先设置成true然后npm run dev 运行之后会生成 .eslintrc-auto-import.json 文件之后,在改为false |
| | | enabled: false, |
| | | filepath: './.eslintrc-auto-import.json', // 生成的文件路径 |
| | | globalsPropValue: true, |
| | | }, |
| | | }), |
| | | PkgConfig(), |
| | | OptimizationPersist() |
| | |
| | | server: { |
| | | open: true, |
| | | host: '0.0.0.0', |
| | | port: 8080 |
| | | port: 8080, |
| | | proxy: { |
| | | '/api': { |
| | | // 代理请求之后的请求地址(你的真实接口地址) |
| | | target: CURRENT_CONFIG.baseURL, |
| | | rewrite: path => path.replace(/^\/api/, ''), |
| | | // 跨域 |
| | | changeOrigin: true |
| | | } |
| | | } |
| | | }, |
| | | envDir: './env', |
| | | resolve: { |