Access Webpack Dev Server from Mobile Safari on an iPhone
Testing your sites on mobile devices is a critical part of the development process. Webpack dev server enables you to visit the server from any device using the host option. This lesson walks you through accessing webpack dev server using an iPhone.
Duration
2 min
Access
Free
Transcript
Available
Testing your sites on mobile devices is a critical part of the development process. Webpack dev server enables you to visit the server from any device using the host option. This lesson walks you through accessing webpack dev server using an iPhone.
Video Transcript
Here I have a basic webpack project which I created with the view CLI. To be able to test this on my phone, I'm going to open my package.json and go into my scripts. This one's called dev, sometimes it's called start like create-react-app, and you'll see it just invokes webpack-dev-server with some options.
I'm going to duplicate this script, and name this safari-dev, because I'm mostly concerned about mobile development on Safari, and then add the flag host 0000and port 3000, so I know exactly which port to open.
Before I run this script, I need to check the IP of my computer on the network, so I'll do that with ifconfig, and you can see I'm at 192.168.1.17. This will be exposed on port 3000.
If I run this yarn safari-dev, and it will say your project is running here, which means I can now access it from my network address. I'll launch this, and you can see my project running at this port.
The next step before you can open this on your phone is to expose port 3000 through your firewall, and depending on your operating system whether Windows, or Mac, or Linux, it's just a simple thing to google, so look how to do that. Once other devices can access this, I'll show on my iPhone here if I go to this address, that it launches the page.
If I come into my project, into one of my files, and I make a change like deleting this logo, hit delete, then save, you'll see it did the hot reload, and the logo disappeared.