feat: handle VITE_PUBLIC_URL
This commit is contained in:
@@ -1,11 +1,20 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
import dotenv from 'dotenv';
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
export default defineConfig(() => {
|
export default defineConfig(() => {
|
||||||
|
const publicUrl = process.env.VITE_PUBLIC_URL || 'http://localhost:5173';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
define: {
|
define: {
|
||||||
'import.meta.env.VITE_BACKEND_URL': JSON.stringify(process.env.VITE_BACKEND_URL),
|
'import.meta.env.VITE_BACKEND_URL': JSON.stringify(process.env.VITE_BACKEND_URL),
|
||||||
|
'import.meta.env.VITE_PUBLIC_URL': JSON.stringify(publicUrl),
|
||||||
},
|
},
|
||||||
|
server: {
|
||||||
|
host: new URL(publicUrl).hostname,
|
||||||
|
port: parseInt(new URL(publicUrl).port),
|
||||||
|
},
|
||||||
build: {
|
build: {
|
||||||
outDir: 'build',
|
outDir: 'build',
|
||||||
manifest: true,
|
manifest: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user