From b05378ea2e6a3177b2863d1fab6293ac14f43467 Mon Sep 17 00:00:00 2001 From: Kamil Niemczycki Date: Sun, 30 Jul 2023 13:33:56 +0200 Subject: [PATCH] - update port for developmnet mode --- .env.example | 1 + vite.config.js | 32 ++++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index 2fea494..fbe18e0 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ VITE_APP_NAME="Kamil Niemczycki CV" VITE_CV_URL="http://localhost:5173" +VITE_PORT=5173 VITE_API_URL="http://localhost" VITE_SOURCE_CODE="https://github.com/kamilniemczycki" diff --git a/vite.config.js b/vite.config.js index 565cb3c..c9332f3 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,13 +1,25 @@ -import { defineConfig, splitVendorChunkPlugin } from 'vite' -import vue from '@vitejs/plugin-vue' +import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import { networkInterfaces } from 'os'; // https://vitejs.dev/config/ -export default defineConfig({ - plugins: [ vue(), splitVendorChunkPlugin() ], - resolve: { - vue: 'vue/dist/vue.esm-bundler.js', - }, - build: { - chunkSizeWarningLimit: 2048, - }, +export default defineConfig((mode) => { + const env = loadEnv(mode, process.cwd(), ""); + return { + server: { + //host: Object.values(networkInterfaces()).flat().find(i => i.family === 'IPv4' && !i.internal).address, + host: 'localhost', + port: parseInt(env.VITE_PORT ?? 5173), + hmr: { + host: 'localhost', + }, + }, + plugins: [ vue(), splitVendorChunkPlugin() ], + resolve: { + vue: 'vue/dist/vue.esm-bundler.js', + }, + build: { + chunkSizeWarningLimit: 2048, + }, + }; });