Enter Your Email Address to Watch This Lesson

Your link to unlock this lesson will be sent to this email address.

Unlock this lesson and all 984 of the free egghead.io lessons, plus get JavaScript content delivered directly to your inbox!



Existing egghead members will not see this. Sign in.

Access Webpack Dev Server from Mobile Safari on an iPhone

1:36 JavaScript lesson by

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.


egghead.io comment guidelines

Avatar
egghead.io

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.

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 0.0.0.0 and 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.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?