diff --git a/front_end/.env.development b/front_end/.env.development index d8fcfe0b..90583712 100644 --- a/front_end/.env.development +++ b/front_end/.env.development @@ -1,2 +1,4 @@ -VITE_APP_SERVER_URL = '' -VITE_APP_MODE = 'dev' +VITE_APP_API_HOST= +VITE_APP_API_PREFIX=/api/local_doc_qa +VITE_APP_WEB_PREFIX=/qanything + diff --git a/front_end/.env.production b/front_end/.env.production new file mode 100644 index 00000000..e30b4ec5 --- /dev/null +++ b/front_end/.env.production @@ -0,0 +1,3 @@ +VITE_APP_API_HOST=http://localhost +VITE_APP_API_PREFIX=/api/local_doc_qa +VITE_APP_WEB_PREFIX=/qanything diff --git a/front_end/package.json b/front_end/package.json index 20af80cd..bfc8dfa8 100644 --- a/front_end/package.json +++ b/front_end/package.json @@ -1,12 +1,12 @@ { "name": "ai-demo", - "version": "1.0.0", + "version": "1.0.1", "tagname": "qanything", "scripts": { "dev": "vite", "test": "vite build --mode test", "analyzer": "vite build --mode test", - "build": "vite build --mode prod", + "build": "vite build", "serve": "vite preview --port 5052", "lint-staged": "lint-staged", "cdn-test": "bash ./cicdn.sh test", @@ -62,7 +62,7 @@ "inquirer": "^8.2.0", "lint-staged": "^12.0.2", "prettier": "^2.4.1", - "rollup-plugin-visualizer": "^5.5.2", + "rollup-plugin-visualizer": "^5.12.0", "rxjs": "^7.4.0", "sass": "^1.42.1", "sass-loader": "^12.1.0", diff --git a/front_end/vite.config.ts b/front_end/vite.config.ts index df359d5a..f8c5d2bb 100644 --- a/front_end/vite.config.ts +++ b/front_end/vite.config.ts @@ -49,6 +49,8 @@ function resovePath(paths) { } export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd()); + return { plugins: [ Components({ @@ -108,7 +110,7 @@ export default defineConfig(({ mode }) => { outDir: `dist/qanything`, }, - base: '/qanything/', + base: env.VITE_APP_WEB_PREFIX, server: { usePolling: true, port: 5052, @@ -119,10 +121,10 @@ export default defineConfig(({ mode }) => { }, cors: true, proxy: { - '/local_doc_qa': { - target: 'http://localhost:8777/api', + [env.VITE_APP_API_PREFIX]: { + target: env.VITE_HOST, changeOrigin: true, - rewrite: path => path.replace(/^\/local_doc_qa/, '/local_doc_qa'), + secure: false, }, }, }, diff --git a/run.ps1 b/run.ps1 index 5db44cbc..16a0b9af 100644 --- a/run.ps1 +++ b/run.ps1 @@ -3,7 +3,11 @@ $content = Get-Content -Raw -Path .\scripts\run_for_local.sh -Encoding utf8 $content = $content -replace "`r$", "" # 移除 BOM -$contentWithoutBOM = $content -replace '^\xEF\xBB\xBF', '' +$content = $content -replace '^\xef\xbb\xbf', '' +$content = $content -replace '^\xff\xfe', '' +$content = $content -replace '^\xfe\xff', '' +$content = $content -replace '^\xff\xfe\x00\x00', '' +$content = $content -replace '^\x00\x00\xfe\xff', '' # 移除文件结尾的空白字符并添加一个新行 $content = $content -replace "\s+$", "`n"