Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Access Webpack Dev Server from Mobile Safari on an iPhone

    John LindquistJohn Lindquist

    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.

    webpackwebpack
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    00:00 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.

    00:18 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.

    00:37 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.

    00:50 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.

    01:06 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.

    01:25 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.

    Discuss

    Discuss