<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mayor David Adewole on Medium]]></title>
        <description><![CDATA[Stories by Mayor David Adewole on Medium]]></description>
        <link>https://medium.com/@mayorsan?source=rss-baeeeb786e15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*idOlcJk83NYpHkJN.jpg</url>
            <title>Stories by Mayor David Adewole on Medium</title>
            <link>https://medium.com/@mayorsan?source=rss-baeeeb786e15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:33:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mayorsan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Copy a File from Mac to AWS EC2 Server]]></title>
            <link>https://medium.com/@mayorsan/how-to-copy-a-file-from-mac-to-aws-ec2-server-babe27ec3ed9?source=rss-baeeeb786e15------2</link>
            <guid isPermaLink="false">https://medium.com/p/babe27ec3ed9</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[mac-os-x]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[technical-writing]]></category>
            <dc:creator><![CDATA[Mayor David Adewole]]></dc:creator>
            <pubDate>Wed, 10 Jul 2024 11:12:55 GMT</pubDate>
            <atom:updated>2024-07-10T11:12:55.242Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6q_BacsxFEqYzqlUY5a2Bw.png" /><figcaption>Copying a File from Mac to AWS EC2 Server: Steps and Commands</figcaption></figure><p><strong>Introduction</strong></p><p>Transferring files between your Mac and AWS EC2 server is a common task for managing remote servers. This guide will show you how to easily and securely copy files using the `scp` command.</p><p><strong>Step-by-Step Guide</strong></p><p>1. <strong>Open Terminal on Your Mac</strong><br>- <strong>Why: </strong>Terminal is the command-line interface you’ll use to run the `scp` command.<br><strong>- How:</strong> Find it in Applications &gt; Utilities, or use Spotlight to search for it.</p><p>2. <strong>Navigate to the Directory with Your File</strong><br><strong>- Why:</strong> You need to be in the directory where the file you want to copy is located.<br><strong>- How:</strong> Use the `<em>cd</em>` command. For example:<br> ```<em>cd /path/to/your/file</em>```</p><p>3.<strong> Use `<em>scp</em>` Command to Copy the File</strong><br><strong>- Why:</strong> The `<em>scp</em>` command securely transfers files using SSH, ensuring encrypted communication.<br>- <strong>How: </strong><br> ```<em>scp -i /path/to/your-key-pair.pem /path/to/local/file username@ec2-instance-public-dns:/path/to/remote/directory </em>```<br> — <strong>Replace placeholders as follows:</strong><br> — `<em>/path/to/your-key-pair.pem</em>`: Path to your EC2 key pair file.<br> — `<em>/path/to/local/file</em>`: Path to the file you want to copy.<br> — `<em>username</em>`: Typically `<em>ec2-user</em>` for Amazon Linux, `<em>ubuntu</em>` for Ubuntu instances, etc.<br> — `<em>ec2-instance-public-dns</em>`: Public DNS of your EC2 instance.<br> — `<em>/path/to/remote/directory</em>`: Directory on the EC2 instance where you want to copy the file.</p><p><strong>Example Command</strong><br>Suppose your key pair file is in `<em>~/.ssh/my-key-pair.pem</em>`, the file you want to copy is `~/Documents/myfile.txt`, and you want to copy it to the home directory of an Amazon Linux instance with the public DNS `<em>ec2–12–34–56–78.compute-1.amazonaws.com</em>`:<br>```<em>scp -i ~/.ssh/my-key-pair.pem ~/Documents/myfile.txt </em><a href="/service/mailto:ec2-user@ec2-12-34-56-78.compute-1.amazonaws.com"><em>ec2-user@ec2–12–34–56–78.compute-1.amazonaws.com</em></a><em>:~</em>```</p><p><strong>Conclusion</strong></p><p>Using the `<em>scp</em>` command allows you to efficiently and securely transfer files from your Mac to your AWS EC2 server. This method ensures your data remains protected during the transfer.</p><p><strong>Additional Resources</strong></p><p>For more details, refer to the [AWS EC2 User Guide on Transferring Files to Linux Instances](<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html#AccessingInstancesLinuxSCP">https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html#AccessingInstancesLinuxSCP</a>).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=babe27ec3ed9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is VPC Flow Logs in AWS?]]></title>
            <link>https://medium.com/@mayorsan/what-is-vpc-flow-logs-in-aws-5fcf3622c7d9?source=rss-baeeeb786e15------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fcf3622c7d9</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-vpc]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[vpc-flow-logs]]></category>
            <dc:creator><![CDATA[Mayor David Adewole]]></dc:creator>
            <pubDate>Thu, 13 Aug 2020 20:48:37 GMT</pubDate>
            <atom:updated>2020-08-13T20:59:58.616Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, I learned about VPC Flow logs, it is a feature that allows you to monitor and capture traffic flow to and from network interfaces within a VPC. <br>It can be used when you want to:</p><ul><li>Diagnose overly restrictive security group rules.</li><li>Monitor the traffic that is reaching your instance(s).</li><li>Determine the direction of the traffic to and from the network interfaces.</li></ul><p>An example use case is when you want to monitor the traffic to and from your RDS instance and your web application.</p><p>VPC Flow logs can be applied at a VPC, Subnet or Network Interface level. When Flow logs is applied to the VPC, it monitors every network interface in that VPC. A monitor on the VPC covers all the subnets in that VPC. <br>When it is applied at the subnet level, it monitors only the network interfaces in that subnet. A monitor on the subnet covers all interfaces in that subnet.<br>When applied directly to a network interface, it only monitors traffic on that particular interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*RnoR8umnr_kx7iOx6P5FtA.png" /><figcaption>In the following example copied directly from the <a href="https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html">official documentation</a>, you create a flow log (fl-aaa) that captures accepted traffic for the network interface for instance A1 and publishes the flow log records to an Amazon S3 bucket. And a second flow log that captures all traffic for subnet B and publishes the flow log records to Amazon CloudWatch Logs. The flow log (fl-bbb) captures traffic for all network interfaces in subnet B. There are no flow logs that capture traffic for instance A2&#39;s network interface.</figcaption></figure><p>One thing to take note of is that, VPC Flow logs can only capture packet metadata, Flow Logs does not monitor packet contents, that requires a packet sniffer. You can read more about packet sniffing <a href="https://www.paessler.com/it-explained/packet-sniffing">here</a>.<br>If there’s any packet flow in a network that you need to observe from the outside, VPC Flow logs can do the job for you, it can capture metadata like the source IP address, destination IP address, ports, protocol, packet size and <a href="https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html#flow-logs-fields">other externally visible metadata</a>.</p><p>VPC Flow logs are not real-time, there’s often a delay in between traffic entering or leaving monitored interfaces and resources. That means you can’t rely on Flow logs to provide real-time telemetry for your network’s packet flow. It uses an <a href="https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html#flow-logs-aggregration-interval">aggregation interval</a> to capture and aggregate a flow into the flow log record.</p><p>As shown in the example diagram above, Flow Logs can be stored on S3 or CloudWatch Logs as a destination. <br>By default, the maximum aggregation interval is 10 minutes. When you create a flow log, you can optionally specify a maximum aggregation interval of 1 minute. Just take note that, Flow logs with a maximum aggregation interval of 1 minute produce a higher volume of flow log records than flow logs with a maximum aggregation interval of 10 minutes.<br>After data is captured within an aggregation interval, it takes additional time to process and publish the data to CloudWatch Logs or Amazon S3. This additional time could be up to 5 minutes to publish to CloudWatch Logs, and up to 10 minutes to publish to Amazon S3.</p><p>For further reading check the documentation of the VPC Flow logs <a href="https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fcf3622c7d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to introduce Terraform into an existing project.]]></title>
            <link>https://medium.com/@mayorsan/how-to-introduce-terraform-into-an-existing-project-f6c39647c125?source=rss-baeeeb786e15------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6c39647c125</guid>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[iaac]]></category>
            <dc:creator><![CDATA[Mayor David Adewole]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 10:46:43 GMT</pubDate>
            <atom:updated>2020-08-13T20:58:25.196Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*jS4FYUwWOtyx-rmljxAfZQ.jpeg" /></figure><h3>Introduction</h3><p>I was asked in an interview to explain, as a Terraform developer and AWS engineer, how I would integrate Terraform into an existing project and development team, to ensure that the team is in sync. How do we create isolated deployments for multiple environments? like test, development and production environments? How do we manage the terraform state for each and every change made before a new deployment?</p><p>As an AWS Engineer, managing the resources for a project start to become difficult and cumbersome after launching a few of the resources through the AWS Console UI. When provisioning multiple AWS resources, tasks that would take at least 10mins to complete using the UI console, could easily be done through the AWS CLI in half the time. It will even take less than that to spin up the same resources if they are provisioned using the concept known as infrastructure as code.</p><blockquote>This is where Terraform comes in, it is a tool for building, changing and managing infrastructure in a safe, repeatable way.</blockquote><p>Teams can use terraform to manage environments with a configuration language called the HashiCorp Configuration Language (HCL) for human-readable, automated-deployments.</p><p>Infrastructure as Code (IaaC) is the process of managing infrastructure in a file or files rather than manually configuring resources in a user interface (UI).</p><h3>How Terraform Works</h3><p>A simple workflow for deployment will follow closely to the steps below.</p><p>1. Scope — Confirm what resources need to be created for a given project</p><p>2. Author — Create the configuration file in HCL based on the scoped parameters</p><p>3. Initialize — Run <strong><em>terraform init</em></strong> command in the project directory with the configuration files. This will download the correct provider plug-ins for the project.</p><p>4. Plan &amp; Apply — Run <strong><em>terraform plan</em></strong> command to verify the creation process and then <strong><em>terraform apply</em></strong> command to create real resources as state file that compares future changes in your configuration files to what actually exists in your deployment environment.</p><h3>Managing Terraform State</h3><p>Terraform creates a state file when a project is first initialised. Terraform uses this local state to create plan and make changes to your infrastructure. Prior to any operation, Terraform does a refresh to update the state with the real infrastructure. This means that Terraform state is the source of truth by which configuration changes are measured. If a change is made or a resource is appended to a configuration, Terraform compares those changes with the state file to determine what changes result in a new resource or resource modifications.</p><h3>Managing Multiple Environments with Terraform</h3><p>With Terraform you can build, change and destroy infrastructure from your local machine/your computer. This is great for testing and development, but in production environments it is considered best practice to store state elsewhere than your local machine. The best way to do this is by running Terraform in a remote environment with shared access to state.<br>Terraform supports team-based workflows with a feature known as <a href="https://www.terraform.io/docs/backends/index.html">remote backends</a>. Remote backends allow Terraform to use a shared storage space for state data, so any member of your team can use Terraform to manage the same infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6c39647c125" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails + Angular + Webpacker Gem Like a Pro.]]></title>
            <link>https://medium.com/@mayorsan/rails-angular-webpacker-gem-like-a-pro-7cf40a588ab9?source=rss-baeeeb786e15------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cf40a588ab9</guid>
            <category><![CDATA[webpacker]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Mayor David Adewole]]></dc:creator>
            <pubDate>Tue, 14 Nov 2017 14:51:42 GMT</pubDate>
            <atom:updated>2017-11-14T15:28:00.361Z</atom:updated>
            <content:encoded><![CDATA[<p>Rails + Angular + Webpacker Gem Like a Pro.</p><p>Webpacker gem in Rails lets you implement an additional pipeline for building modern frontend Javascript alongside your Rails application using popular frameworks like Angular.</p><p><a href="https://webpack.js.org/">Webpack</a>, if you are not yet familiar with it, is a module bundler. It’s main purpose is to bundle Javascript files for usage in a browser, yet it is also capable of transforming, bundling or packaging. It is an asset pipeline that supports most of the modern features of frontend web development along with everything we are used to from Sprockets.</p><p>Before the Webpacker gem was introduced in Rails version ≥ 5.1, people experienced a lot of difficulties trying to configure Rails to work with Webpack. A large portion of the Rails community, most especially the big enterprises were beginning to move their asset pipeline management away from <a href="https://github.com/rails/sprockets">Sprockets </a>(the default Rails library for compiling and serving web assets) to Webpack.</p><p><strong>But why is it so important to migrate from Sprocket to Webpack? You may be wondering by now.</strong></p><p>In the last few years it became clear that Sprockets could no longer keep up with the pace at which the frontend web development ecosystem is evolving. Regular problems such as support for the latest releases of frameworks such as <a href="http://sass-lang.com/">Sass</a> (the CSS extension language), lack of source maps and a drop in support for compressed assets which eventually made compilation of assets extremely slow made it important to migrate from Sprockets to Webpack. Between <a href="https://www.google.ru/search?q=rails+sprockets+webpack&amp;newwindow=1&amp;biw=1240&amp;bih=699&amp;source=lnt&amp;tbs=cdr%3A1%2Ccd_min%3A2015%2Ccd_max%3A2016&amp;tbm=">2015 to 2016</a> a lot of companies switched their asset management from Sprockets to Webpack.</p><p>So in December 2016 DHH announced Webpacker</p><h3>DHH on Twitter</h3><p>Rails 5.1 will ship with Yarn to manage JS dependencies and --webpack to compile app-like JS via Webpacker: https://t.co/iWFNgO87d3</p><p>The main purpose of this post is to introduce how to use Webpacker in your Rails project beyond the basics that we see in articles all over the internet. Personally, I feel like the Rails community has a personal beef with Angular. Almost no one is writing about Rails and Angular integration. I’d taken note of this as far back as last year when the full version of Angular 2 was released and I could not find a single post on how to consume Rails API resources in Angular. So I started a YouTube channel that is dedicated to that. <a href="https://www.youtube.com/channel/UCBUvuSmXyDz8fvAYrisHrrw/videos?view_as=subscriber">Check this link for some video tutorials</a>.</p><p>This is going to be a series of posts addressing some of the most important aspects for a Rails project such as Consuming Rails API data in Angular, Allowing Angular to handle Routing, Server side enabled Pagination and more.</p><p>So lets go ahead and create a Rails project already.</p><p><strong>NB:</strong> I assume that you have the latest version of Ruby, Rails and Postgres installed on your machine so I won’t be talking about how to do that.</p><p>We are going to use Postgres as our database, it uses SQLite by default. We will also skip using TurboLinks because it’s going to clash with the Javascript we’ll be writing when we start using Angular, And also going to skip spring installation and Test:Unit installation because well, most people use RSpec these days. So if you have Rails and Ruby installed on your machine, go ahead and run this command in your command line, that would be the Terminal on a Mac.</p><pre>rails new angular-webpacker-app --skip-turbolinks --skip-spring --skip-test -d postgresql </pre><p>The rails new command created a new rails application as you would expect. Let’s go ahead and change the current directory to that of the app we just created and also open the folder in your favorite text editor.</p><pre><strong>➜ </strong>cd angular-webpacker-app</pre><pre><strong>➜ angular-webpacker-app</strong> <strong>git:(master) ✗ </strong>subl . // Run this command - subl . to open the current directory in Sublime Text. </pre><p>Next we will set up the database, so go ahead and run the next command.</p><p>NB: Take note that <strong>➜ angular-webpacker-app</strong> <strong>git:(master) ✗ </strong>from now on signifies the start of a command line.</p><pre><strong>➜  angular-webpacker-app</strong> <strong>git:(master) ✗ </strong>rails db:create</pre><p>The result of the command above <strong>rails db:create</strong> , if everything goes well on your end is:</p><p>Created database ‘angular-webpacker-app_development’<br>Created database ‘angular-webpacker-app_test’</p><p>So now we can run the rails server to see the rails app in action.</p><pre><strong>➜  angular-webpacker-app</strong> <strong>git:(master) ✗ </strong>rails server</pre><p>You can now visit <a href="http://localhost:3000/">http://localhost:3000</a> to see the new Rails 5.1 welcome page as shown in the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z8wdj_LIvg2j9Aydsj9Q5A.png" /><figcaption>Rails new app welcome page</figcaption></figure><p>Now we will create a simple page which we will use to validate and test that we’ve installed and added Webpack successfully. We will call this page <strong>home</strong>. So open up the route.rb file located in the config folder. My route.rb file now looks like this:</p><pre>Rails.application.routes.draw do<br>  root to: &quot;home#index&quot;<br>end</pre><p>Next, create a controller file <strong>app/controllers/home_controller.rb: <br></strong>my home_controller.rb file now looks like this.</p><pre>class HomeController &lt; ApplicationController<br>  def index<br>  end<br>end</pre><p>Finally, create app/views/home/index.html.erb with some content:</p><pre>&lt;header&gt;<br>  &lt;h1&gt;<br>    Welcome Home. <br>  &lt;/h1&gt;<br>  &lt;section&gt;<br>    &lt;p&gt;<br>      Home of the Webpacker App.<br>    &lt;/p&gt;<br>  &lt;/section&gt;<br>  &lt;h6&gt;We&#39;re using Rails &lt;%= Rails.version %&gt;&lt;/h6&gt;<br>&lt;/header&gt;</pre><p>Now reload your app and you should see the page we’ve created.</p><p>So now that you have a working Rails app, let’s install Bootstrap, this requires learning how to use <a href="https://yarnpkg.com/en/">Yarn</a> to install Webpack, which will serve up our CSS and Javascript files (this is when Webpack replaces Sprockets).</p><p>We use Yarn to manage our Project’s dependencies like <a href="https://angular.io/">Angular</a>, <a href="https://getbootstrap.com/">Bootstrap CSS</a> and other Javascript libraries then use Webpack to serve it up in the browser. Rails version ≥ 5.1 includes support for Yarn by default. As mentioned above Sprockets is missing most of the modern features of frontend web development. If you want to use Javascript framework like Angular then you will need some features that are not available with Sprockets. Now let’s go ahead and install Yarn.</p><p>If you are on a Mac and you already use Homebrew, I advise you to install yarn by running the brew command. This is based on personal experience. <br>I had some issues with Yarn installation on my Mac in the past because of conflict in versions of yarn installed through NPM and Brew, that limited some of my projects from working. So if you are installing Yarn by NPM stick to that and if you are using Homebrew stick to that as well. It is not advisable to have both installations from NPM and Brew on your machine at the same time. I prefer the brew installation because I get the most updated version all the time just by running <strong>brew upgrade</strong>, which updates all my brew packages. So to install yarn run the following command. Btw, also note that you’ll need to install <a href="http://nodejs.org/">Node</a> to get Yarn to work.<a href="https://yarnpkg.com/lang/en/docs/install/"> Check this install page to see different ways to install yarn on different machines</a></p><pre>brew install yarn</pre><p>Next, let’s install and configure Webpacker. <br>Rails 5.1 includes and optional gem called <a href="https://github.com/rails/webpacker">Webpacker</a> that is the official way to use Webpack in a Rails application. Webpacker includes a set of generators and helpers that creates a Webpack configuration. So first we will add it to our Gemfile:</p><pre>gem &#39;rails&#39;, &#39;~&gt; 5.1.4&#39;<br>&gt;&gt; gem &#39;webpacker&#39; // Add webpacker gem to your Gemfile<br>gem &#39;pg&#39;, &#39;~&gt; 0.18&#39;</pre><p>Then we will install it with Bundler by running</p><pre><strong>➜  angular-webpacker-app</strong> <strong>git:(master) ✗</strong> bundle install</pre><p>We can now use Webpacker to install and configure Webpack for our Project by using the Rails task, <strong>webpacker:install<br></strong>Run the following command:</p><pre><strong>➜  angular-webpacker-app</strong> <strong>git:(master) ✗</strong> rails webpacker:install</pre><p>If all goes well, you should see a very long output, a lot of files were created, most of which are created to configure Webpack, and you will also see that a file called <strong>package.json</strong> has been created in the root of your application. This file is analogous to the Gemfile in that it lists third-party libraries that we will use in our application.<br>Running <strong>yarn install</strong> is the Javascript equivalent of <strong>bundle install</strong>.</p><p>Our development workflow with Webpack requires a second server to be run that serves up our Javascript and CSS. Unlike with Sprockets, which executes inside our Rails app when we run <strong>rails server</strong>, Webpacker runs outside of Rails using it’s own server, called webpack-dev-server (which is already added to the devDependencies in your package.json file). This means we need a way to run this server, but also a way to tell our Rails views to get Javascript and CSS from this server.</p><p>The command to serve up our Webpack-managed code is <strong>bin/webpack-dev-server. </strong>While we could run this in another window alongside the already running <strong>rails server,</strong> that’s rather cumbersome and inconvenient. Instead we can use a Ruby gem called <strong>Foreman. </strong>Foreman allows us to specify any number of commands to run at the same time and in the same window. First, let’s install Foreman by adding it to your Gemfile and running <strong>bundle install</strong> afterwards:</p><pre>gem &#39;rails&#39;, &#39;~&gt; 5.1.4&#39;<br>gem &#39;webpacker&#39;<br>&gt;&gt; gem &#39;foreman&#39; // Add foreman to your Gemfile.</pre><p>To configure Foreman, list all the commands you want to run in a file called <strong>Procfile.</strong> The format of a Procfile is a series of lines, each having a name, followed by a colon, followed by the command to run. <br>For our purpose we want to run both <strong>rails server</strong> and <strong>bin/webpack-dev-server. </strong>So create Procfile in the root directory of your Rails app and add the following code like so:</p><pre>//angular-webpacker-app/Procfile</pre><pre>rails:   bundle exec rails server<br>​webpack: bin/webpack-dev-server</pre><p>Now you can run these commands with the single command line <strong>foreman start. </strong>Now this will be the way you should run your Rails + Webpacker application from this point onward.</p><p>NB: Take note that <strong>rails server</strong> which was running earlier on now needs to be stopped for <strong>foreman start</strong> to run successfully. You will also notice that Foreman is running on <a href="http://localhost:5000/">http://localhost:5000/</a>. Go ahead and give it a try!</p><p>With this in place, we can now serve up Javascript and CSS managed by Webpack to our Rails application. To verify that this is true let’s bring in Bootstrap into our application. Navigate to <strong>app/javascript/packs/application.js</strong> a file that was created by Webpacker during the installation. It includes a welcome code</p><pre>console.log(&#39;Hello World from Webpacker&#39;)</pre><p>Let’s get this to show in the console of our browser. To do that, we’ll use the helper methods provided by the Webpacker gem. <strong>javascript_pack_tag</strong> to serve up Javascript files and <strong>stylesheet_pack_tag</strong> to serve up CSS files. We will add them in our main application layout file. So navigate to <strong>app/views/layouts/application.html.erb </strong>and add the following code:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;AngularWebpackerApp&lt;/title&gt;<br>    &lt;%= csrf_meta_tags %&gt;</pre><pre>    &lt;%= stylesheet_link_tag    &#39;application&#39;, media: &#39;all&#39; %&gt;<br>    &lt;%= javascript_include_tag &#39;application&#39; %&gt;</pre><pre>    <strong>&gt;&gt;</strong> &lt;%= stylesheet_pack_tag    &#39;application&#39; %&gt;<br>    <strong>&gt;&gt;</strong> &lt;%= javascript_pack_tag    &#39;application&#39; %&gt;<br>  &lt;/head&gt;</pre><pre>  &lt;body&gt;<br>    &lt;%= yield %&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>If you refresh you browser now you will get an error:<br><strong>ActionView::Template::Error (Webpacker can’t find application.css in /Users/mayor/YouTubeClasses/angular-webpacker-app/public/packs/manifest.json. </strong>That’s because of course we are importing the application file using <strong>stylesheet_pack_tag</strong> but there is no corresponding application.css file so let’s go ahead and create that. <br>Create <strong>app/javascript/packs/application.css:<br></strong>Let’s just increase the font-size of all HTML elements on page by 50px to verify everything is working fine. Add the following code to application.css</p><pre>html {<br>  font-size: 50px;<br>}</pre><p>Then import the application.css file into the application.js file like so:<br>The reason is that with Webpack, all assets are managed from a JavaScript file. So to tell Webpack to manage a CSS file, we need to import it into the JS file.</p><pre>import &quot;./application.css&quot;;<br>console.log(&#39;Hello World from Webpacker&#39;)</pre><p>This is the result after refreshing my browser. Depending on your machine, you might need to restart your server to get this to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42NYb_YiKlYC6LWN6sVk7g.png" /><figcaption>The result after refreshing the browser. We imported CSS with Webpacker and served it up in the browser.</figcaption></figure><p>Now let’s download and Set up Bootstrap CSS.</p><p>With Webpack’s initial setup out of the way, bringing in Bootstrap and other Javascript libraries becomes relatively straightforward.</p><pre>// To add the latest version of bootstrap<br><strong>➜  angular-webpacker-app</strong> <strong>git:(master) ✗</strong> yarn add bootstrap@4.0.0-beta.2<br>// To add bootstrap 3<br><strong>➜  angular-webpacker-app</strong> <strong>git:(master) ✗ </strong>yarn add bootstrap@3</pre><p>To use bootstrap in our project we import it by adding the following line in the <strong>app/javascript/packs/application.js</strong> file</p><pre>import &quot;bootstrap/dist/css/bootstrap.css&quot;;</pre><p>If all goes well the font on the page will change to the default Bootstrap.</p><p>That’s all the setup we need to use Webpacker in a Rails application. In the next post we will install Angular and configure it to work seamlessly with our Rails application where we will be consuming a Rails data in the Angular application using TypeScript.</p><p><strong>If you like this tutorial or find it helpful, please give it a clap (up to 50), so other people can see it. Also do not hesitate to ask questions, if any, in the comment below. You can also follow me </strong><a href="https://medium.com/@mayorsan"><strong>on here</strong></a><strong> and on </strong><a href="https://twitter.com/mayordwells"><strong>Twitter</strong></a><strong> to stay updated on the next tutorials. Thanks!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cf40a588ab9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>