Level 58
Yes, you can run multiple sites at the same time using Valet, Sail, and Vite. The key is to configure each site to use a different port on Vite.
Here's how you can do it:
- In your
vite.config.jsfile for each site, you need to specify a different port. For example, forsitea.test, you might have:
export default {
server: {
port: 3000
}
}
And for siteb.test, you might have:
export default {
server: {
port: 3001
}
}
- Then, in your
sailconfiguration, you need to map these ports to your application. You can do this in thedocker-compose.ymlfile. For example:
services:
sitea:
ports:
- '3000:3000'
siteb:
ports:
- '3001:3001'
- Finally, in your
Valetconfiguration, you need to set up a proxy for each site to the corresponding port. You can do this using thevalet proxycommand. For example:
valet proxy sitea http://localhost:3000
valet proxy siteb http://localhost:3001
Now, you should be able to access sitea.test and siteb.test at the same time, each running on its own Vite server.
1 like