From 54849757852f6ab40eb17afbd03d1d839b60a38d Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 13 Nov 2023 17:09:15 +0800
Subject: [PATCH] 重复定时和连续执行
---
vite.config.ts | 221 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 152 insertions(+), 69 deletions(-)
diff --git a/vite.config.ts b/vite.config.ts
index 1eef1cd..a754a27 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,7 +1,7 @@
import vue from '@vitejs/plugin-vue'
// config alias
import path from 'path'
-import { ConfigEnv, defineConfig, UserConfigExport } from 'vite'
+import { ConfigEnv, defineConfig, UserConfigExport, loadEnv } from 'vite'
import ViteComponents, { AntDesignVueResolver } from 'vite-plugin-components'
// Introduce eslint plugin
import eslintPlugin from 'vite-plugin-eslint'
@@ -14,81 +14,164 @@
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
- }),
- ViteComponents({
- customComponentResolvers: [AntDesignVueResolver()],
- }),
- viteSvgIcons({
+export default defineConfig(({ command, mode }) => {
+ // 添加第三个参数空字符串时 '' ,会在env中包含所有环境变量;反之,只包含.env文件中配置的环境变量
+ const env = loadEnv(mode, process.cwd() + '/env')
+ // eslint-disable-next-line no-useless-escape
+ return {
+ plugins: [
+ vue(),
+ cesium(),
+ eslintPlugin({
+ fix: true
+ }),
+ ViteComponents({
+ customComponentResolvers: [AntDesignVueResolver()],
+ }),
+ viteSvgIcons({
// 指定需要缓存的图标文件夹
- iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
- // 指定symbolId格式
- symbolId: 'icon-[dir]-[name]',
- }),
- viteVConsole({
- entry: path.resolve(__dirname, './src/main.ts'), // 入口文件
- 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: {
+ iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
+ // 指定symbolId格式
+ symbolId: 'icon-[dir]-[name]',
+ }),
+ viteVConsole({
+ entry: path.resolve(__dirname, './src/main.ts'), // 入口文件
+ 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()
+ enabled: false,
+ filepath: './.eslintrc-auto-import.json', // 生成的文件路径
+ globalsPropValue: true,
+ },
+ }),
+ PkgConfig(),
+ OptimizationPersist()
// [svgBuilder('./src/assets/icons/')] // All svg under src/icons/svg/ have been imported here, no need to import separately
- ],
- server: {
- open: true,
- host: '0.0.0.0',
- port: 8080,
- proxy: {
- '/uav': {
- // 代理请求之后的请求地址(你的真实接口地址)
- target: CURRENT_CONFIG.baseURL,
- rewrite: path => path.replace(/^\/uav/, ''),
- // 跨域
- changeOrigin: true
+ ],
+ server: {
+ open: true,
+ host: '0.0.0.0',
+ port: 8080,
+ proxy: {
+ [env.VITE_BASE_API]: {
+ // 代理请求之后的请求地址(你的真实接口地址)
+ target: env.VITE_API_URL,
+ rewrite: path => path.replace(new RegExp(`^${env.VITE_BASE_API}`), ''),
+ // 跨域
+ changeOrigin: true
+ }
}
- }
- },
- envDir: './env',
- resolve: {
- alias: [{
+ },
+ envDir: './env',
+ resolve: {
+ alias: [{
// https://github.com/vitejs/vite/issues/279#issuecomment-635646269
- find: '/@',
- replacement: path.resolve(__dirname, './src'),
- }
- ]
- },
- css: {
- preprocessorOptions: {
- scss: {
+ find: '/@',
+ replacement: path.resolve(__dirname, './src'),
+ }
+ ]
+ },
+ css: {
+ preprocessorOptions: {
+ scss: {
// example : additionalData: `@import "./src/design/styles/variables";`
// dont need include file extend .scss
- additionalData: '@import "./src/styles/variables";'
- },
+ additionalData: '@import "./src/styles/variables";'
+ },
+ }
+ },
+ base: './',
+ build: {
+ target: ['es2015'], // 最低支持 es2015
+ sourcemap: true
}
- },
- base: './',
- build: {
- target: ['es2015'], // 最低支持 es2015
- sourcemap: true
}
})
+// export default ({ command, mode }: ConfigEnv): UserConfigExport => defineConfig({
+// plugins: [
+// vue(),
+// cesium(),
+// eslintPlugin({
+// fix: true
+// }),
+// ViteComponents({
+// customComponentResolvers: [AntDesignVueResolver()],
+// }),
+// viteSvgIcons({
+// // 指定需要缓存的图标文件夹
+// iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
+// // 指定symbolId格式
+// symbolId: 'icon-[dir]-[name]',
+// }),
+// viteVConsole({
+// entry: path.resolve(__dirname, './src/main.ts'), // 入口文件
+// 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()
+// // [svgBuilder('./src/assets/icons/')] // All svg under src/icons/svg/ have been imported here, no need to import separately
+// ],
+// server: {
+// open: true,
+// host: '0.0.0.0',
+// port: 8080,
+// proxy: {
+// '/uav': {
+// // 代理请求之后的请求地址(你的真实接口地址)
+// target: CURRENT_CONFIG.baseURL,
+// rewrite: path => path.replace(/^\/uav/, ''),
+// // 跨域
+// changeOrigin: true
+// }
+// }
+// },
+// envDir: './env',
+// resolve: {
+// alias: [{
+// // https://github.com/vitejs/vite/issues/279#issuecomment-635646269
+// find: '/@',
+// replacement: path.resolve(__dirname, './src'),
+// }
+// ]
+// },
+// css: {
+// preprocessorOptions: {
+// scss: {
+// // example : additionalData: `@import "./src/design/styles/variables";`
+// // dont need include file extend .scss
+// additionalData: '@import "./src/styles/variables";'
+// },
+// }
+// },
+// base: './',
+// build: {
+// target: ['es2015'], // 最低支持 es2015
+// sourcemap: true
+// }
+// })
--
Gitblit v1.9.3