@@ -19,6 +19,9 @@ describe('laravel-vite-plugin', () => {
1919
2020 const serveConfig = plugin . config ( { } , { command : 'serve' , mode : 'development' } )
2121 expect ( serveConfig . base ) . toBe ( '' )
22+ expect ( buildConfig . server . host ) . toBeUndefined ( )
23+ expect ( buildConfig . server . port ) . toBeUndefined ( )
24+ expect ( buildConfig . server . strictPort ) . toBeUndefined ( )
2225
2326 const ssrConfig = plugin . config ( { build : { ssr : true } } , { command : 'build' , mode : 'production' } )
2427 expect ( ssrConfig . base ) . toBe ( '/build/' )
@@ -188,4 +191,30 @@ describe('laravel-vite-plugin', () => {
188191
189192 expect ( config . resolve . alias ) . toContainEqual ( { find : 'ziggy' , replacement : 'vendor/tightenco/ziggy/dist/index.es.js' } )
190193 } )
194+
195+ it ( 'configures the Vite server when inside a Sail container' , ( ) => {
196+ process . env . LARAVEL_SAIL = '1'
197+ const plugin = laravel ( )
198+
199+ const config = plugin . config ( { } , { command : 'serve' , mode : 'development' } )
200+ expect ( config . server . host ) . toBe ( '0.0.0.0' )
201+ expect ( config . server . port ) . toBe ( 5173 )
202+ expect ( config . server . strictPort ) . toBe ( true )
203+
204+ delete process . env . LARAVEL_SAIL
205+ } )
206+
207+ it ( 'allows the Vite port to be configured when inside a Sail container' , ( ) => {
208+ process . env . LARAVEL_SAIL = '1'
209+ process . env . VITE_PORT = '1234'
210+ const plugin = laravel ( )
211+
212+ const config = plugin . config ( { } , { command : 'serve' , mode : 'development' } )
213+ expect ( config . server . host ) . toBe ( '0.0.0.0' )
214+ expect ( config . server . port ) . toBe ( 1234 )
215+ expect ( config . server . strictPort ) . toBe ( true )
216+
217+ delete process . env . LARAVEL_SAIL
218+ delete process . env . VITE_PORT
219+ } )
191220} )
0 commit comments