temp
This commit is contained in:
@@ -5,6 +5,7 @@ import autoprefixer from 'autoprefixer';
|
||||
import path from 'path';
|
||||
import nesting from 'tailwindcss/nesting';
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const isKV = process.env.VITE_USE_KV === 'true';
|
||||
const unamiPlugin = {
|
||||
name: 'html-transform',
|
||||
transformIndexHtml(html: string) {
|
||||
@@ -18,17 +19,36 @@ const plugins = [];
|
||||
if (!isDev) {
|
||||
plugins.push(unamiPlugin);
|
||||
}
|
||||
let proxy = {};
|
||||
if (isKV) {
|
||||
proxy = {
|
||||
'/api': {
|
||||
target: 'https://envision.xiongxiao.me',
|
||||
changeOrigin: true,
|
||||
rewrite: (path: any) => path.replace(/^\/api/, '/api'),
|
||||
},
|
||||
'/api/router': {
|
||||
target: 'wss://envision.xiongxiao.me',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
rewriteWsOrigin: true,
|
||||
rewrite: (path: any) => path.replace(/^\/api/, '/api'),
|
||||
},
|
||||
'/resources': {
|
||||
target: 'https://envision.xiongxiao.me',
|
||||
changeOrigin: true,
|
||||
rewrite: (path: any) => path.replace(/^\/resources/, '/resources'),
|
||||
},
|
||||
};
|
||||
}
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(), ...plugins],
|
||||
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: [
|
||||
nesting, // 作用是可以使用@import导入css文件
|
||||
tailwindcss,
|
||||
autoprefixer,
|
||||
],
|
||||
// @ts-ignore
|
||||
plugins: [nesting, tailwindcss, autoprefixer],
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
@@ -60,6 +80,7 @@ export default defineConfig({
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/resources/, '/resources'),
|
||||
},
|
||||
...proxy,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user