Front end development - Hopstok/rock-recepies GitHub Wiki

Front-end development

Local

  • Clone repo from github
  • run npm i to install external packages
  • run ng serve or npm run start to start application and listen it on port 4200

Test app on a external device

The device needs to use the same internet connection.

  • run ng serve --port=0.0.0.0
  • find your ip (ifconfig on MacOS)
  • open a browser in the device and text <your-ip-address>:4200 into url

Test service worker

During development you'll be able to use service worker through localhost, but to deploy it on a site you'll need to have HTTPS setup on your server.

Because ng serve does not work with service workers, you must use a separate HTTP server to test your project locally.

  1. ng build --prod
  2. install http-server npm package with npm install -g http-server
  3. run http-server -p 8080 -c-1 dist/<project-name>
  4. to simulate a network issue, disable network interaction for your application. In Chrome:
    • select Tools > Developer Tools (from the Chrome menu located at the top right corner).
    • go to the Network tab.
    • check the Offline box.

Now you can check that a service worker is enabled by going to chrome://inspect/#service-workers and looking for your site.