haha
This commit is contained in:
@@ -3,12 +3,31 @@ import react from "@vitejs/plugin-react";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import path from "path";
|
||||
|
||||
// 云服务器公网 IP:设置环境变量 PUBLIC_HOST=139.196.48.8 可在控制台显示公网访问地址
|
||||
const publicHost = process.env.PUBLIC_HOST;
|
||||
const port = 1420;
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
port: 1420,
|
||||
host: true, // 监听 0.0.0.0,支持公网 IP / 云服务器访问
|
||||
port,
|
||||
host: true, // 监听 0.0.0.0,支持公网访问
|
||||
allowedHosts: publicHost ? [publicHost] : undefined,
|
||||
},
|
||||
plugins: [react(), tailwindcss()],
|
||||
plugins: [
|
||||
react(),
|
||||
tailwindcss(),
|
||||
// 云服务器:启动时打印公网访问地址
|
||||
publicHost
|
||||
? {
|
||||
name: "log-public-url",
|
||||
configureServer() {
|
||||
return () => {
|
||||
console.log(`\n ➜ 公网: http://${publicHost}:${port}/\n`);
|
||||
};
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
].filter(Boolean),
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
|
||||
Reference in New Issue
Block a user