File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,9 @@ export default function laravel(config: string|string[]|PluginConfig): LaravelPl
7979 server : {
8080 origin : '__laravel_vite_placeholder__' ,
8181 ...( process . env . LARAVEL_SAIL ? {
82- host : '0.0.0.0' ,
83- port : env . VITE_PORT ? parseInt ( env . VITE_PORT ) : 5173 ,
84- strictPort : true ,
82+ host : userConfig . server ?. host ?? '0.0.0.0' ,
83+ port : userConfig . server ?. port ?? ( env . VITE_PORT ? parseInt ( env . VITE_PORT ) : 5173 ) ,
84+ strictPort : userConfig . server ?. strictPort ?? true ,
8585 } : undefined )
8686 } ,
8787 resolve : {
Original file line number Diff line number Diff line change @@ -195,6 +195,24 @@ describe('laravel-vite-plugin', () => {
195195 delete process . env . VITE_PORT
196196 } )
197197
198+ it ( 'allows the server configuration to be overridden inside a Sail container' , ( ) => {
199+ process . env . LARAVEL_SAIL = '1'
200+ const plugin = laravel ( 'resources/js/app.js' )
201+
202+ const config = plugin . config ( {
203+ server : {
204+ host : 'example.com' ,
205+ port : 1234 ,
206+ strictPort : false ,
207+ }
208+ } , { command : 'serve' , mode : 'development' } )
209+ expect ( config . server . host ) . toBe ( 'example.com' )
210+ expect ( config . server . port ) . toBe ( 1234 )
211+ expect ( config . server . strictPort ) . toBe ( false )
212+
213+ delete process . env . LARAVEL_SAIL
214+ } )
215+
198216 it ( 'prevents the Inertia helpers from being externalized' , ( ) => {
199217 /* eslint-disable @typescript-eslint/ban-ts-comment */
200218 const plugin = laravel ( 'resources/js/app.js' )
You can’t perform that action at this time.
0 commit comments