<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chukwunonso Orjiakor</title>
    <description>The latest articles on DEV Community by Chukwunonso Orjiakor (@chuksjoe).</description>
    <link>https://dev.to/chuksjoe</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F122719%2F79d136ce-66da-4a63-81b3-c1e539a05dca.jpeg</url>
      <title>DEV Community: Chukwunonso Orjiakor</title>
      <link>https://dev.to/chuksjoe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chuksjoe"/>
    <language>en</language>
    <item>
      <title>How to transform a React app built on Webpack to PWA</title>
      <dc:creator>Chukwunonso Orjiakor</dc:creator>
      <pubDate>Tue, 12 May 2020 20:01:42 +0000</pubDate>
      <link>https://dev.to/chuksjoe/how-to-transform-a-react-app-built-on-webpack-to-pwa-glb</link>
      <guid>https://dev.to/chuksjoe/how-to-transform-a-react-app-built-on-webpack-to-pwa-glb</guid>
      <description>&lt;p&gt;Early this month, in my spare time I was able to transform one of my Solo React projects into a Progressive Web App (PWA). I accomplished this in less than a day and I will be writing on how I achieved this feat in this article.&lt;/p&gt;

&lt;p&gt;First thing first, for some of you that are not familiar with PWA. According to &lt;a href="https://en.wikipedia.org/wiki/Progressive_web_application" rel="noopener noreferrer"&gt;Wikipedia&lt;/a&gt;, "A progressive web application (PWA) is a type of application software delivered through the web, built using common web technologies including HTML, CSS and JavaScript. It is intended to work on any platform that uses a standards-compliant browser. Functionality includes working offline, push notifications, and device hardware access, enabling creating user experiences similar to native applications on desktop and mobile devices".&lt;/p&gt;

&lt;p&gt;List of companies that are currently using it for their user-facing apps is endless and it includes big names like Twitter, Instagram, Telegram, AliExpress, FlipBoard just to mention a few.&lt;/p&gt;

&lt;h1&gt;
  
  
  Pre-requisites
&lt;/h1&gt;

&lt;p&gt;Before forging ahead with this article I expect you to have a working React application that is built on Webpack. Also, it will be a plus if the app is responsive and mobile-friendly, as this will give the users a feel of a native mobile app or desktop app.&lt;/p&gt;

&lt;h1&gt;
  
  
  Steps
&lt;/h1&gt;

&lt;p&gt;To successfully transform a react app built on webpack into a PWA, we will be creating a manifest file and a service worker that will help us to achieve our aim. Read through the below steps to see how I accomplished it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create The Manifest File
&lt;/h2&gt;

&lt;p&gt;According to this &lt;a href="https://web.dev/add-manifest/" rel="noopener noreferrer"&gt;article&lt;/a&gt;, "The web app manifest is a JSON file that tells the browser about your Progressive Web App and how it should behave when installed on the user's desktop or mobile device. A typical manifest file includes the app name, the icons the app should use, and the URL that should be opened when the app is launched".&lt;br&gt;
The manifest file is best put in the public folder where the &lt;code&gt;index.html&lt;/code&gt; file can easily access it. Below is a sample of what the manifest file looks like in its simplest form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "short_name": "Football Update",
  "name": "Live Football Score Update",
  "icons": [
    {
      "src": "../images/favicon.gif",
      "sizes": "64x64",
      "type": "image/gif"
    },
    {
      "src": "../images/football-logo.png",
      "type": "image/png",
      "sizes": "256x256"
    }
  ],
  "start_url": "../",
  "display": "standalone",
  "theme_color": "#27ae60",
  "background_color": "#fff"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can read more on the manifest file and its properties &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Manifest" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For the manifest file to take effect, ensure you deploy it in the &lt;code&gt;index.html&lt;/code&gt; file by adding the below line of code in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="manifest" href="manifest/manifest.json" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Generate The Service Worker
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://medium.com/@sandoche" rel="noopener noreferrer"&gt;Sandoche ADITTANE&lt;/a&gt; in one of his articles titled &lt;a href="https://medium.com/learning-lab/how-pwas-works-and-how-i-implemented-it-with-react-and-webpack-523381b1b7a4" rel="noopener noreferrer"&gt;How PWAs works and how I implemented it with React and Webpack&lt;/a&gt; described Service Worker as thus: "A service worker is a script that runs in the background of your browser separated from your website. You can use this script to cache files, send a push notification or do other background tasks like updating your page for example".&lt;/p&gt;

&lt;p&gt;This helps to cache files such as logos, favicons, manifest and other resources that make the PWA run smoothly in the browser. You can read more on it from the above link or &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API" rel="noopener noreferrer"&gt;here&lt;/a&gt; or &lt;a href="https://developers.google.com/web/fundamentals/primers/service-workers" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To generate the Service Worker, you will have to add Webpack's Workbox plugin in your &lt;code&gt;webpack.config.js&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;First, install the workbox-webpack-plugin node module by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install workbox-webpack-plugin --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, in your &lt;code&gt;webpack.config.js&lt;/code&gt;, add the following lines of code that starts with a +:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const path = require('path');
  const webpack = require('webpack');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  const CopyWebpackPlugin = require('copy-webpack-plugin');
+ const WorkboxPlugin = require('workbox-webpack-plugin');
  const Dotenv = require('dotenv-webpack');

  module.exports = {
    ...
    plugins: [
      new Dotenv({
        safe: true,
        systemvars: true
      }),
      new HtmlWebpackPlugin({
 -      title: 'Football Update',
 +      title: 'Football Update WPA',
        template: path.resolve('public/index.html')
      }),
 +    new WorkboxPlugin.GenerateSW({
 +      // these options encourage the ServiceWorkers to get in there fast
 +      // and not allow any straggling "old" SWs to hang around
 +      clientsClaim: true,
 +      skipWaiting: true
 +    }),
      new CopyWebpackPlugin([
        { from: 'public/images', to: 'images' },
 +      { from: 'public/manifest', to: 'manifest' }
      ]),
      new webpack.HotModuleReplacementPlugin()
    ]
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the above addition, you will generate the Service Worker, and also expose the manifest file folder so that it can be accessed by the web browser.&lt;/p&gt;

&lt;p&gt;When you run: &lt;code&gt;npm build&lt;/code&gt; or &lt;code&gt;yarn build&lt;/code&gt; in your project terminal, the Service Worker files should be generated as shown in the image below:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0tzeugjl47nnz95hfbhg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0tzeugjl47nnz95hfbhg.png" alt="Generate Service Worker" width="702" height="500"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Register Your Service Worker
&lt;/h2&gt;

&lt;p&gt;Once Service Worker has been generated and you have your &lt;code&gt;manifest.json&lt;/code&gt; file in the right place, open your &lt;code&gt;index.js&lt;/code&gt; file which is the entry point into your app, and add the following codes to register the Service Worker.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  import React from 'react';
  import ReactDom from 'react-dom';

  import App from './App';
  import './assets/styles/index.css';

  ReactDom.render(&amp;lt;App /&amp;gt;, document.getElementById('root'));

+ if ('serviceWorker' in navigator) {
+   window.addEventListener('load', () =&amp;gt; {
+     navigator.serviceWorker.register('/service-worker.js')
+    .then(registration =&amp;gt; {
+       console.log('SW registered: ', registration);
+     }).catch(registrationError =&amp;gt; {
+       console.log('SW registration failed: ', registrationError);
+     });
+   });
+ }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, you have successfully created and linked the &lt;code&gt;manifest.json&lt;/code&gt; to the &lt;code&gt;index.html&lt;/code&gt; for your PWA, and also generated and registered a Service Worker for the background activities on the browser. You can now run your app to see the beauty of a PWA.&lt;/p&gt;

&lt;p&gt;Here is a link to the PWA I built in this process: &lt;a href="https://footballscores.netlify.app/" rel="noopener noreferrer"&gt;https://footballscores.netlify.app/&lt;/a&gt;.&lt;br&gt;
It is an app that keeps football lovers updated with football matches scores, and it's still a work in progress which I add new features to whenever am less busy.&lt;br&gt;
See screenshot of the app on a mobile device below:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbhigsh6fua6c6kqebpft.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbhigsh6fua6c6kqebpft.jpg" alt="Football App Screenshot" width="800" height="1422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you visit the link on your Android mobile device, it will prompt you to add the PWA icon to your home screen. Also, on your desktop browser (particularly Google Chrome version 70 and above), a plus (+) button appears at the right of the address bar when you visit the link. Click on it to add the icon of the WPA to your desktop like a native application.&lt;/p&gt;

&lt;p&gt;Thanks for journeying with me through this article. Your feedback and comments will be highly appreciated. Kindly leave your comments in the comment section.&lt;/p&gt;

</description>
      <category>wpa</category>
      <category>react</category>
      <category>javascript</category>
      <category>webpack</category>
    </item>
    <item>
      <title>I Finally Got It Hosted!</title>
      <dc:creator>Chukwunonso Orjiakor</dc:creator>
      <pubDate>Sat, 23 Mar 2019 16:27:48 +0000</pubDate>
      <link>https://dev.to/chuksjoe/i-finally-got-it-hosted-8ea</link>
      <guid>https://dev.to/chuksjoe/i-finally-got-it-hosted-8ea</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmoxhp8mu70d1rsxbfl3h.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmoxhp8mu70d1rsxbfl3h.jpg" alt="man holding fireworks by Go to Riley McCullough"&gt;&lt;/a&gt;&lt;br&gt;
Wow! I did it. After so much anticipation and some touch of uncertainty, I finally hosted MY FIRST REAL PROJECT for &lt;a href="https://Astromaticng.com" rel="noopener noreferrer"&gt;Astromatic Nig. Ltd&lt;/a&gt;. And not just that, I am also publishing my first ever personal post on &lt;a href="//https:/dev.to"&gt;Dev.to&lt;/a&gt; on my Birthday Day.&lt;/p&gt;

&lt;p&gt;I am a &lt;strong&gt;&lt;em&gt;'Web Developer Convert'&lt;/em&gt;&lt;/strong&gt; who had spent lot of time learning languages like java, and c++, done projects using visual basic 6 during my National Diploma(ND) programme, and have spent some more time doing computer repair, maintenance and upgrade while running my Higher National Diploma(HND) programme. I was hope to go straight to software development without touching web development at all. But all that changed with time, and right now web development is quite unavoidable as the internet and web browsers has taken over from desktop native app, and is still on the rise.&lt;/p&gt;

&lt;p&gt;I have always wanted to experiment with something real after my HND project which in a way was the starting point in my career path and very pivotal in my becoming a full stack web developer. Then I started learning HTML/CSS, JavaScript, PHP and MySQL, and it took my about 3months to kick-start the project work. The project was a replicate of a cloud storage platform where users can upload, download and delete their files, and also manage their profiles. The test running and defense of the project I and my team members actually did by hosting the app locally using WAMP and a wireless router which enabled us to test run the app on other devices. Ever since, I have always wanted to continue with the project and have already started by hosting it on &lt;a href="https://www.000webhost.com" rel="noopener noreferrer"&gt;000webhost.com&lt;/a&gt; and having the files uploaded on &lt;a href="https://github.com/chuksjoe/cloudhere" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. You can check it out here: &lt;a href="https://cloud-here.000webhostapp.com" rel="noopener noreferrer"&gt;Cloud-Here.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After my HND programme, I started playing more with codes and increasing my programming skills and also applying for a junior developer role where I could learn more from experienced developers and understand better the act of software engineering. Sadly am still on the search. Though, along the line came this wonderful opportunity via a friend, and it was about building their company's website.&lt;/p&gt;

&lt;p&gt;I was asked to meet with their then BDM who enquired if I had worked on any project before. I made it clear to him that I was a starter, and the only project I had to show was my online profile page. I showed it to him. It was my first and only project as at then that was hosted on a free hosting space courtesy my application for an internship programme at &lt;a href="https://bincom.net" rel="noopener noreferrer"&gt;Bincom&lt;/a&gt; in which I was asked to develop a single page online profile with my CV content without using any framework. I wasn't called up for the programme, so I took time to work on the profile page to make it better, and I have been using it ever since as my profile page. &lt;a href="https://chuksjoe.github.io" rel="noopener noreferrer"&gt;You can check it out here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the BDM saw it, he was pleased and promised to convince the owner of the company. I was convinced within me that I could actually handle the project given how well I have practiced, and when the owner of the company agreed to my proposal I kicked off immediately even without them committing financially, to show them my willingness. I wasn't driven by the money I will make from it, I was majorly hungry for exposure and experience with a real project.&lt;/p&gt;

&lt;p&gt;The initial stage of the project was quite stressful and challenging beyond what I had expected from the onset, because after numerous research on how a real project is being done, I was expecting a meeting where I will get to meet the relevant stakeholders to decide what the site should look like, what the contents should be, the design pattern they will prefer, and stuffs like that, but this never happened. I became content developer, front-end developer, back-end developer, SEO engineer,  even graphics designer in just one project.&lt;br&gt;
Awesome right?!!! Yeah, it was indeed a great experience and was fun, because it made me researched a lot more than expected. Though, it took me more time to get the project to a hostable state, but it was finally and surely accomplished. &lt;a href="https://Astromaticng.com" rel="noopener noreferrer"&gt;You can check the project out here. &lt;/a&gt;&lt;br&gt;
Please kindly review it, as your feedbacks and criticisms will be highly welcomed and appreiated.&lt;/p&gt;

&lt;h1&gt;
  
  
  ABOUT THE PROJECT
&lt;/h1&gt;

&lt;p&gt;The project which I call a web app given the dynamic nature of some part of its contents is a company website for &lt;a href="https://Astromaticng.com" rel="noopener noreferrer"&gt;Astromatic Nigeria Limited&lt;/a&gt; that tells about the company, what they sell and what they do. It also has a products section/page where their goods are showcased and it's backend for the staffs who will be uploading their products to the e-commerce platform.&lt;/p&gt;

&lt;p&gt;I chose not to use any framework or library other than jQuery, and bootstrap (whose usage is very minimal) so as to increase my understanding of how things work together internally and to have a broader knowledge of the actual codes. Even the e-commerce section and it's backend, I had to hard-code in vanilla PHP to build my experience and understanding of the language, and it really paid off.&lt;/p&gt;

&lt;p&gt;In the course of the project my HTML/CSS, JavaScript, PHP, MySQL and graphics design skills were brushed up and boosted, also I got to put my software development and project management theoretical knowledge into practice. Working with the Agile methodology, am still adding more features to the project as the need arises.&lt;/p&gt;

&lt;p&gt;In all these, the experience gotten has been incredibly great, and I really can't wait to take on more projects. Though, I still wish and desire to work under more experienced developers/engineers who will mentor me and guide my growth, and also get to work more within a team to boost my collaboration skills.&lt;/p&gt;

&lt;p&gt;I am highly open to working with any company that has a growth mindset not just for the company alone, but also for its workers. Though, right now I'm freelancing and ready to take on any web project.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href="https://dev.to"&gt;Dev.to&lt;/a&gt; for this wonderful platform to exercise my writing skills, and &lt;strong&gt;HAPPY BIRTHDAY TO ME \O/!!!&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>firstpost</category>
      <category>fullstack</category>
      <category>webdeveloper</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
