<?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: Mitch Pierias</title>
    <description>The latest articles on DEV Community by Mitch Pierias (@mitchpierias).</description>
    <link>https://dev.to/mitchpierias</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%2F122391%2Fc43c2c5e-d5e2-4743-9332-0ff903e52289.jpeg</url>
      <title>DEV Community: Mitch Pierias</title>
      <link>https://dev.to/mitchpierias</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mitchpierias"/>
    <language>en</language>
    <item>
      <title>A Complete Electron Application Production Pipeline!</title>
      <dc:creator>Mitch Pierias</dc:creator>
      <pubDate>Mon, 04 Feb 2019 03:51:00 +0000</pubDate>
      <link>https://dev.to/mitchpierias/a-complete-electron-application-production-pipeline-2973</link>
      <guid>https://dev.to/mitchpierias/a-complete-electron-application-production-pipeline-2973</guid>
      <description>&lt;p&gt;I shared a blog post about configuring a complete electron application production pipeline, you can &lt;a href="https://medium.com/@mitchpierias/the-complete-electron-pipeline-development-to-rollout-63668dd46649"&gt;visit the medium post here&lt;/a&gt; if you'd like to read more.&lt;/p&gt;




&lt;p&gt;Alternatively, a copy of the article is below. I've tried to reproduce styling as best I can within this Markdown editor, sorry for any inconsistencies &lt;/p&gt;




&lt;p&gt;This article aims to outline a complete Electron development to rollout project pipeline. I’ll be covering everything from creating your initial Electron boilerplate with React, all the way through to building and publishing to an Amazon AWS S3 Bucket. We will then look at creating a static Gatsby site to list our distributions, delving into automatic S3 deployment and utilizing CloudFront and Route 53. The complete project for this can be &lt;a href="https://github.com/MitchPierias/Agora"&gt;found on Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s get our project started by laying out our boilerplate, we’re going to make this easier by using &lt;code&gt;create-reacton-app&lt;/code&gt;. Short disclaimer, I wrote it… so if your having problems, sorry! Okay back to work, install &lt;code&gt;create-reactron-app&lt;/code&gt; globally and then execute with your &lt;code&gt;PROJECT_NAME&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g create-reactron-app
create-reactron-app PROJECT_NAME
cd PROJECT_NAME
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It’s that simple! Now you have a fully fledged Electron app with React boilerplate! You can run &lt;code&gt;npm run start&lt;/code&gt; to open a development environment or &lt;code&gt;npm run build &amp;amp;&amp;amp; npm run dist&lt;/code&gt; to compile distribution binaries. It’s up to you what you’d like your app to do and look like from here. In the next section we will look at publish your distributions so their available to anyone!&lt;br&gt;
Publishing Distributions&lt;/p&gt;

&lt;p&gt;Let’s look at deploying out binaries for public access using an Amazon AWS S3. You’ll need to setup an &lt;strong&gt;Amazon AWS account&lt;/strong&gt; before we start an hopefully have experience with the AWS services.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting your credentials
&lt;/h2&gt;

&lt;p&gt;Login to your &lt;strong&gt;AWS account&lt;/strong&gt; and access the &lt;strong&gt;IAM&lt;/strong&gt; service, navigating into the &lt;strong&gt;users&lt;/strong&gt; area. Select &lt;strong&gt;Add User&lt;/strong&gt; and specify a name for the user who will access this projects deployment bucket, I named mine after my project &lt;code&gt;agora-deploy&lt;/code&gt;. Tick &lt;strong&gt;Programmatic access&lt;/strong&gt; and proceed to &lt;strong&gt;Set permissions&lt;/strong&gt;. Here you want to search for &lt;strong&gt;‘S3’&lt;/strong&gt; and select the &lt;strong&gt;S3-Manager&lt;/strong&gt; permission. This will grant full access to S3 instances, primarily the read-write we need. Finally &lt;strong&gt;Add Tags&lt;/strong&gt;, &lt;strong&gt;Review&lt;/strong&gt; and &lt;strong&gt;Create user&lt;/strong&gt; once you’ve configured any extras. Be sure to copy the &lt;code&gt;access_key_id&lt;/code&gt; and &lt;code&gt;access_secret_key&lt;/code&gt; displayed, we will need these later to configure the AWS-CLI. The permissions for your new user should now contain at least the following.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AH6VCRSw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AjoSvez9wfGh58jHuGInEFg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AH6VCRSw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AjoSvez9wfGh58jHuGInEFg.png" alt="IAM Access Permissions"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  AWS Command Line Interface
&lt;/h2&gt;

&lt;p&gt;Please follow the instructions on the following link to &lt;a href="https://aws.amazon.com/cli/"&gt;install and setup AWSCLI for your operating system&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you’ve got the command line tools setup, open the credentials file with &lt;code&gt;nano ~/.aws/credentials&lt;/code&gt; and insert the keys we copied early when creating a new &lt;strong&gt;IAM user&lt;/strong&gt;. I’ve named my configuration &lt;code&gt;agora-deploy&lt;/code&gt;, this is useful if you have multiple projects with separate AWS access on your system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[agora-deploy]
aws_access_key_id=JFRSHDKGYCNFPZMWUTBV
aws_secret_access_key=FK84mfPSdRtZgpDqWvb04fDen0fr3DZ87hTYEE1n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  S3 Buckets
&lt;/h2&gt;

&lt;p&gt;Now that you’ve setup your command line, navigate back to AWS console and create a new bucket to hold your distribution binaries. Just use the default settings when creating the bucket, then navigate through the Permissions and into the Bucket Policy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eRO-uAZp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AE7qMVUhxPi4OH-GuoO0yKg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eRO-uAZp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AE7qMVUhxPi4OH-GuoO0yKg.png" alt="Bucket policy permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Insert the following policy, granting public access to GetObject’s from the bucket. Be sure to insert &lt;code&gt;YOUR_BUCKET_ARN&lt;/code&gt; followed by the top level directory your opening, I used &lt;code&gt;/*&lt;/code&gt; here for all contents.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "YOUR_BUCKET_ARN/*"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And your set, the buckets now ready to serve your distribution. You could manually upload the build files, or continue onto the next section were we will look at automating distribution publishing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Electron-Builder
&lt;/h2&gt;

&lt;p&gt;We need to add some additional configuration to our Electron build properties for our new S3 instance. Add the following publish settings to your &lt;code&gt;package.json&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"build": {
  ...
  "publish": [
    {
      "provider":"s3",
      "bucket":"YOUR_BUCKET_NAME"
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I also updated my &lt;code&gt;scripts&lt;/code&gt; with the following two commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  ...
  "dist": "electron-builder --publish never --linux --mac",
  "release": "npm run dist --publish always"
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;dist&lt;/code&gt; script compiles binaries without publishing and the &lt;code&gt;release&lt;/code&gt; script executes the &lt;code&gt;dist&lt;/code&gt; script with while overwriting the &lt;code&gt;--publish&lt;/code&gt; flag. If you’ve configured your AWS command line credentials and spelled everything correctly, you should be able to run &lt;code&gt;npm run release&lt;/code&gt; to have electron-builder build and publish your distributions.&lt;/p&gt;

&lt;h1&gt;
  
  
  Content Delivery
&lt;/h1&gt;

&lt;p&gt;Now that we have our application project setup, building and publishing, we can move onto creating our web interface to help user easily find the installer they need. The source code for this section can be found at the &lt;a href="https://github.com/MitchPierias/Agora-Static"&gt;following GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;I’m going to be building a static site to list the distributions. For this I’ll be using Gatsby and configuring automatic publishing to S3, and served from CloudFront. Let’s start by installing Gatsby’s command line interface tools, then run &lt;code&gt;gatsby new&lt;/code&gt; followed by our application name to create our project boilerplate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g gatsby-cli
gastby new APP_NAME
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I’ll quickly add links to the binaries using the S3 Object URL within the &lt;code&gt;index.js&lt;/code&gt; component. You can build your site out however you’d like here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Link to=”https://s3-ap-southeast-2.amazonaws.com/agora-distribution/Agora-0.2.3.dmg”&amp;gt;Mac&amp;lt;/Link&amp;gt;
&amp;lt;Link to=” https://s3-ap-southeast-2.amazonaws.com/agora-distribution/Agora+0.2.3.AppImage”&amp;gt;Linux&amp;lt;/Link&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Finally we can run &lt;code&gt;npm run build&lt;/code&gt; to compile our static site, then move onto configuring our S3 and CloudFront environment to display it. The output of our build will be in the public folder, the contents of this folder is what we will move to our S3 Bucket.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please be aware that some AWS services can take up to 24 hours to propagate changes across all edge locations, and be discoverable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before we can begin, you’ll need to have a domain name ready. We could do this with the resource URL’s generated for our instances, but there’s really no reason you’d ever need to do such a thing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring HTTPS
&lt;/h2&gt;

&lt;p&gt;As a bonus to our users, we’re going to setup SSL so they can trust we really are who we say we are. Within the AWS console, navigate to the &lt;strong&gt;Certificate Manager&lt;/strong&gt; and &lt;strong&gt;Request a certificate&lt;/strong&gt;. Follow the prompts to setup, entering your domain or multiple domains, and selecting &lt;strong&gt;DNS Validation&lt;/strong&gt; as the validation method.&lt;/p&gt;

&lt;p&gt;Once your certificate has been requested, you’ll need to follow the instructions listed to complete issuance. It may take up too an hour for Route 53 and Certificate Manager to synchronize and issue the certificate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aFdEMqG6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/600/1%2AUx2dnQLHWk2jsLlOfRYQrA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aFdEMqG6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/600/1%2AUx2dnQLHWk2jsLlOfRYQrA.png" alt="Configuring S3 Access"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  S3 Hosting
&lt;/h2&gt;

&lt;p&gt;We’re going to need an S3 bucket to hold all our static build files. Open S3 and create a new bucket, using your domain name as the bucket’s name. Next open the bucket settings navigate to Properties and configure your Static website hosting like so. We’re telling our bucket to act as a web server, returning the specified index document when no resource is specified and the error document when a resource isn’t found. We will set ours as the default files outputted from Gatsby’s build process. We don’t need to configure our bucket policy yet, we will have CloudFront do that later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Cloudfront
&lt;/h2&gt;

&lt;p&gt;We could configure our S3 Bucket to directly serve our content, but then we loose the advantage of SSL encryption and high speed delivery. Let’s setup a CloudFront instance instead to build an edge cache from our bucket contents and deliver it with SSL. Open the CloudFront Service within AWS, Create Distribution, and Get Started with a Web distribution. We have a little bit to configure here so stay patient.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Origin Settings&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Origin Domain Name: YOUR_S3_BUCKET_ARN&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Default Cache Behavior Settings&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Viewer Protocol Policy: Redirect HTTP to HTTPS&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Distribution Settings&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSL Certificate: Custom SSL Certificate &lt;em&gt;(Select the cert assigned earlier)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Default Root Object: &lt;code&gt;index.html&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can setup any additional configuration here you like, like custom headers. Next select Create Distribution and Amazon will start up the new instance. This will take some time, go have a coffee while the instance starts and propagates across all edge locations. We will need the service to be discoverable for the next section, configuring Route 53.&lt;/p&gt;

&lt;h2&gt;
  
  
  Domain Routing
&lt;/h2&gt;

&lt;p&gt;So we’ve setup CloudFront to cache and serve our static site from S3, now we need to configure Route53 to provide a user friendly domain for our CloudFront instance. Navigate over to &lt;strong&gt;Route53&lt;/strong&gt;, select the Hosted Zone associated with your domain, or create one if you haven’t already. Then Create Record Set, type &lt;code&gt;A — IPv4 address&lt;/code&gt;, select Alias Yes and set the Alias Target as your CloudFront instance. Again, the CloudFront instance could take up too 24 hours to appear across other services. Once this is setup, you should be able to visit your domain after a few minutes and see your static site appear.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automating S3 Deployment
&lt;/h2&gt;

&lt;p&gt;We previous manually copied the entire contents of the build folder into our S3 bucket. There’s nothing technically wrong with this… but we’re all about automation and making things simpler! So let’s setup &lt;code&gt;gatsby-plugin-s3&lt;/code&gt; to deploy our build to S3 in just one command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -s gatsby-plugin-s3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then we want to configure the plugin within our &lt;code&gt;gatsby-config.js&lt;/code&gt; file. Add the following configuration object into the plugins array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins: [
  ...
  {
    resolve: 'gatsby-plugin-s3',
    options: {
      bucketName: 'agora.pierias.com'
    }
  }
  ...
]

Finally we’re going to add a deploy command to the package.json like so:

"scripts": {
  ...
  "deploy": "gatsby-plugin-s3 deploy"
  ...
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Before you can run this you’ll need to call &lt;code&gt;npm run build&lt;/code&gt; to update the plugins in &lt;code&gt;.cache&lt;/code&gt;, then you can run the &lt;code&gt;npm run deploy&lt;/code&gt; command, following the prompts to deploy to S3. Remember to setup your &lt;code&gt;~/.aws/credentials&lt;/code&gt; with your &lt;code&gt;AWS_ACCESS_KEY_ID&lt;/code&gt; and &lt;code&gt;AWS_SECRET_ACCESS_KEY&lt;/code&gt; from the AWS IAM service. More details on &lt;a href="https://www.gatsbyjs.org/packages/gatsby-source-s3/"&gt;the S3 plugin can be found here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you!
&lt;/h3&gt;

&lt;p&gt;You should now have a full production pipeline setup. We could also add a GraphQL query to our Gatsby site in order to fetch the latest build resource URL from our deployment S3 Bucket. If you’d like to visit the live website deployed in this example, it can be found at &lt;a href="https://agora.pierias.com"&gt;Agora&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>electron</category>
      <category>react</category>
      <category>aws</category>
      <category>gatsby</category>
    </item>
    <item>
      <title>The Dream Team — React with Electron</title>
      <dc:creator>Mitch Pierias</dc:creator>
      <pubDate>Tue, 18 Dec 2018 00:08:56 +0000</pubDate>
      <link>https://dev.to/mitchpierias/the-dream-teamreact-with-electron-474d</link>
      <guid>https://dev.to/mitchpierias/the-dream-teamreact-with-electron-474d</guid>
      <description>&lt;p&gt;So you ‘re either a React developer dabbling into the world of electron, or your looking to extend the abilities of Electron. Either way, you’ve ended up here because you’ve asked yourself the same question that took me down the rabbit hole, “How can I use React inside Electron?”.&lt;/p&gt;

&lt;p&gt;I’m not going to be making anything spectacular in this example. To be honest, I had trouble compiling my own Electron project with React, so I simplified everything down to this boilerplate template. In this example, we’re simply going to make React compile our basic project, then build our application distributions using Electron. The complete code for this example can be found &lt;a href="https://github.com/MitchPierias/React-Electron-Boilerplate"&gt;here on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the Project
&lt;/h2&gt;

&lt;p&gt;Before we can start building our electron application we first need to install a few dependencies and define our project structure. Firstly, create a new directory for your project and navigate inside, then run &lt;code&gt;npm init&lt;/code&gt; and fill out the prompts to create your project boilerplate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir reactron &amp;amp;&amp;amp; cd reactron
npm init
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we’re ready to start installing our dependencies like React and React DOM! We’re also installing path as a production dependency cause we will be using it in with Electron later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save react react-dom path
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I’m not going to go over the React code, that could take a very long time depending on how far we choose to go. So I’m going to assume you know the basics. If not, you can just copy the files in the &lt;code&gt;./src&lt;/code&gt; directory from the &lt;a href="https://github.com/MitchPierias/React-Electron-Boilerplate"&gt;GitHub repo&lt;/a&gt; and follow &lt;a href="https://www.google.com/search?q=Learn+React"&gt;one of these tutorials&lt;/a&gt; if you’d like to learn more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Webpack Setup
&lt;/h2&gt;

&lt;p&gt;Now we need to compile our React project down into a single bundle, for this we will use Webpack.&lt;br&gt;
&lt;/p&gt;

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



&lt;p&gt;We’re also going to need webpack loaders like babel, style loaders and html compilers, let’s install those and delve a little deeper into what they do.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev babel-core@6 babel-loader@7 babel-preset-env@1 babel-preset-react@6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Babel is the loader responsible for parsing all our fancy new-age Javascript into the currently supported specification ES5.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;babel-core:&lt;/strong&gt; Transforms your ES6 code into ES5.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;babel-loader:&lt;/strong&gt; Webpack helper plugin to parse ES6 dependencies into ES5.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;babel-preset-env:&lt;/strong&gt; Determines which transformations/plugins to use and polyfills.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;babel-preset-react:&lt;/strong&gt; Presets for all React plugins.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev css-loader style-loader html-webpack-plugin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;style-loader:&lt;/strong&gt; Compiles the referenced css files in our React components and injects them into the build file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;css-loader:&lt;/strong&gt; Is the parser to help Webpack interpret and transform our CSS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;html-webpack-plugin:&lt;/strong&gt; Outputs a compiled html file with resources adn tags linked.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There’s going to be allot of dependencies building up now… don’t worry, it’s just because of Webpacks extensability. Let’s define our project structure and start coding our resources, your project should resemble something like the following;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Reactron
|- assets
  ...react-assets...
|- build
  |- bundle.js
  |- index.html
|- dist
  ...electron-build-files...
|- node_modules
  ...installed-modules...
|- src
  |- index.js
  |- index.html
  |- index.css
|- package.json
|- main.js
|- webpack.config.js
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuring Webpack
&lt;/h2&gt;

&lt;p&gt;Now we’re ready to start configuring Webpack to bundle our React project and resources into our &lt;code&gt;./build&lt;/code&gt; directory for Electron. To start, open &lt;code&gt;webpack.config.js&lt;/code&gt; and import the webpack, path and &lt;code&gt;html-webpack-plugin&lt;/code&gt; modules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const webpack = require('webpack');
const path = require('path');
const HtmlWebPackPlugin = require("html-webpack-plugin");
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  HTML-Webpack-Plugin
&lt;/h3&gt;

&lt;p&gt;The html-webpack-plugin will take care of compiling our entry &lt;code&gt;index.html&lt;/code&gt; file after webpack has done it's magic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const htmlPlugin = new HtmlWebPackPlugin({
 title: "Reactron",
 template: "./src/index.html",
 filename: "./index.html"
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then we will configure our &lt;code&gt;html-webpack-plugin&lt;/code&gt;. This will handle injecting resources and data into our &lt;code&gt;./src/index.html&lt;/code&gt; template through the Webpack build process, outputting the compiled result along with the bundled Javascript into the output directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Webpack Build Pipeline
&lt;/h3&gt;

&lt;p&gt;Now we are finally ready to configure our Webpack build pipline. Below everything we just wrote, define the following;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
 entry: './src/index.js',
 target: 'electron-renderer',
 output: {
  path: path.resolve(__dirname, 'build'),
  publicPath: './',
  filename: 'bundle.js'
 },
 module: {
  rules: [
   {
    test: /\.js$/,
    exclude: [
     /node_modules/,
     /.json?/
    ],
    use: {
     loader: 'babel-loader',
     query: {
      presets: ["env","react"]
     }
    }
   }, {
    test: /\.(s*)css$/,
    use: ['style-loader','css-loader']
   }
  ]
 },
 plugins:[
  htmlPlugin
 ],
 resolve: {
  extensions: ['.js','.jsx']
 }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I don’t want too delve deep into Webpack, but you can read the the official documentation and examples here if you’d like to explore it further. This code snippet is essentially telling Webpack where our entry file is, where we want to output, and using what modules and plugins.&lt;/p&gt;

&lt;h2&gt;
  
  
  Electron
&lt;/h2&gt;

&lt;p&gt;We’ve now build our Electron renderer with React, bundled with Webpack, and now we’re ready to begin coding our Electron application to serve it all.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev electron
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Coding our Electron Application
&lt;/h3&gt;

&lt;p&gt;Let’s open the &lt;code&gt;./main.js&lt;/code&gt; file and copy in the following;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { app, BrowserWindow } = require('electron');
const path = require('path');

let mainWindow = null;

function createWindow() {

 mainWindow = new BrowserWindow({
  width:600,
  height:400
 });

 mainWindow.loadFile(path.resolve(__dirname,'build/index.html'));

 mainWindow.on('closed', () =&amp;gt; {
  if (process.platform !== 'darwin') app.quit();
 });
}

app.on('ready', createWindow);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is the absolute minimum code to start an Electron application. We’re importing our modules path and the app and BrowserWindow components from electron, then defining an empty mainWindow reference and &lt;code&gt;createWindow()&lt;/code&gt; function before attaching it to the &lt;code&gt;app.on(‘ready’)&lt;/code&gt; event. Our c&lt;code&gt;reateWindow&lt;/code&gt; function is initializing a new &lt;code&gt;BrowserWindow&lt;/code&gt;, loading the &lt;code&gt;./build/index.html&lt;/code&gt; file we compiled with Webpack earlier, and handling the &lt;code&gt;mainWindow.on(‘closed’)&lt;/code&gt; event.&lt;br&gt;
Running the App&lt;/p&gt;

&lt;p&gt;And that’s it! We can execute &lt;code&gt;npm webpack --mode production&lt;/code&gt; to compile and then &lt;code&gt;npm electron .&lt;/code&gt; to start our Electron application. Let’s complete our project by compiling everything into a distribution with electron-builder.&lt;/p&gt;
&lt;h2&gt;
  
  
  Electron Builder
&lt;/h2&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev electron-builder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The Build Property
&lt;/h3&gt;

&lt;p&gt;The majority of our electron-builder configuration happens inside the &lt;code&gt;build&lt;/code&gt; property within our &lt;code&gt;package.json&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"build": {
  "productName":"Reactron",
  "appId":"com.reactron.app",
  "directories": {
    "buildResources":"build",
    "output":"dist"
  }
  ...
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We’re defining our &lt;code&gt;productName&lt;/code&gt; which is self explanatory and the &lt;code&gt;appId&lt;/code&gt; which is typically a unique identifier like a URL on the web. The important property is the directories, here you’ll specify the &lt;code&gt;buildResources&lt;/code&gt; where Electron will find your bundled Webpack output, and the output setting which defines the directory to output the build.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"directories": {
  ...
},
"files": [
  "**/*",
  "build/**/*",
  "node_modules/**/*"
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we specify the files to scan and package into our application bundle and we’re ready to run!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node electron-builder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>react</category>
      <category>electron</category>
      <category>javascript</category>
      <category>babel</category>
    </item>
  </channel>
</rss>
