Make web runtime scripts self contained
This commit is contained in:
@@ -16,9 +16,9 @@
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "pnpm vite build --mode production",
|
||||
"build:analyze": "pnpm vite build --mode analyze",
|
||||
"dev": "pnpm vite --mode development",
|
||||
"build": "vite build --mode production",
|
||||
"build:analyze": "vite build --mode analyze",
|
||||
"dev": "vite --mode development",
|
||||
"preview": "vite preview",
|
||||
"typecheck": "vue-tsc --noEmit --skipLibCheck"
|
||||
},
|
||||
|
||||
@@ -3,16 +3,21 @@ import { defineConfig } from '@vben/vite-config';
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
|
||||
import ElementPlus from 'unplugin-element-plus/vite';
|
||||
import { loadEnv } from 'vite';
|
||||
|
||||
const resolveLocal = (path: string) =>
|
||||
fileURLToPath(new URL(path, import.meta.url));
|
||||
const appDir = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
const exactAlias = (find: string, path: string) => ({
|
||||
find: new RegExp(`^${find.replaceAll('/', '\\/')}$`),
|
||||
replacement: resolveLocal(path),
|
||||
});
|
||||
|
||||
export default defineConfig(async () => {
|
||||
export default defineConfig(async (config) => {
|
||||
const env = loadEnv(config.mode, appDir);
|
||||
const proxyTarget = env.VITE_PROXY_TARGET || 'http://localhost:8000';
|
||||
|
||||
return {
|
||||
application: {
|
||||
injectMetadata: false,
|
||||
@@ -170,12 +175,12 @@ export default defineConfig(async () => {
|
||||
'/basic-api': {
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/basic-api/, ''),
|
||||
target: 'http://localhost:8000',
|
||||
target: proxyTarget,
|
||||
ws: true,
|
||||
},
|
||||
'/ws': {
|
||||
changeOrigin: true,
|
||||
target: 'ws://localhost:8000',
|
||||
target: proxyTarget.replace(/^http/, 'ws'),
|
||||
ws: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user