45 lines
1001 B
TypeScript
45 lines
1001 B
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import path from 'path';
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
server: {
|
|
hmr: true,
|
|
host: '::',
|
|
allowedHosts: [
|
|
'.mymoyu.top', // 注意是点开头,不是星号
|
|
'localhost',
|
|
'127.0.0.1',
|
|
'192.168.1.4'
|
|
],
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://127.0.0.1:8000',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
bypass: (req) => {
|
|
if (req.headers.accept?.includes('text/html')) {
|
|
return req.url;
|
|
}
|
|
},
|
|
},
|
|
'/ws': {
|
|
target: 'ws://127.0.0.1:8000',
|
|
ws: true,
|
|
rewrite: (path) => path.replace(/^\/ws/, ''),
|
|
},
|
|
'/media/': {
|
|
target: 'http://127.0.0.1:8000',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
})
|