<?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: Abhishek Prasad</title>
    <description>The latest articles on DEV Community by Abhishek Prasad (@abhishek71994).</description>
    <link>https://dev.to/abhishek71994</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%2F178890%2F63bcfc36-0a8c-4ca0-b65a-04e3d738c36c.jpeg</url>
      <title>DEV Community: Abhishek Prasad</title>
      <link>https://dev.to/abhishek71994</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhishek71994"/>
    <language>en</language>
    <item>
      <title>Setup CSS modules in POSTCSS</title>
      <dc:creator>Abhishek Prasad</dc:creator>
      <pubDate>Thu, 07 Nov 2019 10:21:33 +0000</pubDate>
      <link>https://dev.to/abhishek71994/setup-css-modules-in-postcss-2k23</link>
      <guid>https://dev.to/abhishek71994/setup-css-modules-in-postcss-2k23</guid>
      <description>&lt;p&gt;So I was trying to include the modular way of styling sass in my project. Just cuz I feel that it's a convenience for me, no leakage of styles. No strong opinions about it. Initially, I was under the impression that the tech stack that the framework that I was using allowed it i.e. ParcelJS.&lt;/p&gt;

&lt;p&gt;Bear with me as I don't have much idea and I just put stuff in place. Now ParcelJS use PostCSS. &lt;/p&gt;

&lt;p&gt;More information about &lt;a href="https://postcss.org/"&gt;PostCSS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon researching a bit more I realized that there is a command that I can call from the &lt;code&gt;npm start&lt;/code&gt; script. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;"start": parcel --no-hmr src/index.html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RtI1KkL6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/piv4qc01dosc7ae8gfss.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RtI1KkL6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/piv4qc01dosc7ae8gfss.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which makes no sense to me. &lt;/p&gt;

&lt;p&gt;So hmr is Hot module Reloading huh... Looking at this image it seems like the next process to where I am at. As it is, the documentation (&lt;a href="https://parceljs.org/hmr.html"&gt;https://parceljs.org/hmr.html&lt;/a&gt;) states that when you build the app and use it in production, there is no hmr(Hot Module Reload), but it's just for the convenience of the engineer that it's there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/QJKu9V1DTvGI0TWdEa/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/QJKu9V1DTvGI0TWdEa/giphy.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I went up the page and saw that I need to make a file named &lt;code&gt;postcss.config.js&lt;/code&gt; and set&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "modules": true
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Did that, didn't work. * Sigh *&lt;/p&gt;

&lt;p&gt;Check this out for more &lt;a href="https://parceljs.org/transforms.html#postcss"&gt;info&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I can only assume that Parcel people(what I refer to the maintainers), want to keep as much payload away from the dist as possible. So they don't wanna include an out of box solution. Maybe, just an assumption.&lt;/p&gt;

&lt;p&gt;But anyway, how it did work was that I had to make a &lt;code&gt;.postcssrc&lt;/code&gt; file at the root folder and add the above content to it.&lt;/p&gt;

&lt;p&gt;Don't forget to restart the server though. I got stuck at this step for a minute.&lt;/p&gt;

&lt;p&gt;It works! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iAWev2VQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/i897cnytlj21efqvklv4.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iAWev2VQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/i897cnytlj21efqvklv4.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The extra characters are just hashes, I'd assume.&lt;/p&gt;

&lt;p&gt;Hopefully, this was helpful and helps those in need of setting up modular design pattern in ParcelJS.&lt;/p&gt;

&lt;p&gt;By the way, check out my &lt;a href="https://github.com/WrippleFoss/mentorFix"&gt;org&lt;/a&gt; where you can help make some open-source awesomeness and help other devs in the process too.&lt;/p&gt;

&lt;p&gt;Also, do check out &lt;a href="https://careers.myfave.com/"&gt;Fave&lt;/a&gt;, we are hiring.&lt;/p&gt;

</description>
      <category>css</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Trying to deploy stuff on AWS</title>
      <dc:creator>Abhishek Prasad</dc:creator>
      <pubDate>Tue, 08 Oct 2019 10:58:28 +0000</pubDate>
      <link>https://dev.to/abhishek71994/trying-to-deploy-stuff-on-aws-448</link>
      <guid>https://dev.to/abhishek71994/trying-to-deploy-stuff-on-aws-448</guid>
      <description>&lt;p&gt;All that I did last time was write up tests and fix CI.. But now what next? How do I CD the damn thing. I literally have no idea, so hopefully by the end of this blog I do.&lt;br&gt;
Things that I know at the moment...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I need a domain name&lt;/li&gt;
&lt;li&gt;I need to deploy a react app on AWS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AWS, sponsor me if we are successful please. Well, no one would listen anyway. Onto the research and stuff...&lt;/p&gt;

&lt;p&gt;Signing up for AWS??&lt;/p&gt;

&lt;p&gt;Ummmmm obviously...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;waiting for verification code&lt;/li&gt;
&lt;li&gt;IAM? and all that?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/3o6wNYW4Hqk6C1Uu1W/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/3o6wNYW4Hqk6C1Uu1W/giphy.gif" alt="hours later gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now what..&lt;/p&gt;

&lt;p&gt;That was a really long break. I have so much food in me, I cant type. &lt;/p&gt;

&lt;p&gt;Okay so went ahead with AWS Amplify. Looked simple enough and my previous CI stuff makes a bit more sense when I read this. Hoping it would not cause an issue.&lt;/p&gt;

&lt;p&gt;AAHHH SHIT&lt;/p&gt;

&lt;p&gt;Okay let me investigate!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/Sq8KpWNNNBk2I/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/Sq8KpWNNNBk2I/giphy.gif" alt="investigate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Okay so maybe I did not build the app. I guess, I have to configure that in parcel. Well, let's see how to do that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "test": "jest --config=jest.config.json",
    "start": "parcel index.html",
    "build": "parcel build index.html"
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This may not be easy... Because I see that there are a lot of building patterns in the parcel CLI section.&lt;/p&gt;

&lt;p&gt;Merged the branch which has all the new styles into the master..&lt;br&gt;
I fear that I am not utilizing the build power of parcel.&lt;/p&gt;

&lt;p&gt;I feel like I should try and see if I can write my own build file in my codebase.&lt;/p&gt;

&lt;p&gt;Let's try the &lt;code&gt;npm install -g @aws-amplify/cli&lt;/code&gt; way.&lt;/p&gt;

&lt;p&gt;Well I get &lt;code&gt;command not found: amplify&lt;/code&gt;. Stuck!&lt;/p&gt;

&lt;p&gt;The yarn stuff&lt;/p&gt;

&lt;p&gt;Maybe I should run yarn again after removing the &lt;code&gt;node_modules&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Same failure..&lt;/p&gt;

&lt;p&gt;HMMMMMMMMMM&lt;/p&gt;

&lt;p&gt;So I added a pre-build section to the build config.&lt;br&gt;
It seems that after the build the config file cant find the base folder.&lt;/p&gt;

&lt;p&gt;WHAT THE HECK!!!&lt;/p&gt;

&lt;p&gt;So it seems like the build.yml file for Amplify works differently to other platforms.&lt;br&gt;
Usually what happens is.&lt;/p&gt;

&lt;p&gt;Deployment failing.. WHAT IS GOING ON!!! WHY ARE THINGS NOT SIMPLE!&lt;br&gt;
They could have provided a better log record. Gaah!&lt;/p&gt;

&lt;p&gt;I bought a domain now, so, we should see a basic website by the end of this.. if we get there though.&lt;/p&gt;

&lt;p&gt;So it's one day later..&lt;br&gt;
I am still trying to think about it. I think I shall try the good old s3 bucket stuff that I see that my company does.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/1BgNAAaeCr4gcZlMy6/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/1BgNAAaeCr4gcZlMy6/giphy.gif" alt="googling gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/RQdxHi4_Pvc"&gt;https://youtu.be/RQdxHi4_Pvc&lt;/a&gt; (stumbling onto cool youtube video, spending 3-4 hours on youtube&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://open.spotify.com/album/3a3AA8QEvjP7onsoz3jaqc?si=VZYHjHJVTFmqrIr-rzSo3A"&gt;https://open.spotify.com/album/3a3AA8QEvjP7onsoz3jaqc?si=VZYHjHJVTFmqrIr-rzSo3A&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Created a S3 bucket --&amp;gt; Setup Permission policy --&amp;gt; A lot of aws stuff and phew&lt;/p&gt;

&lt;p&gt;Got it running! But now I want to have my domain name which I bought, route here. Hmmmm Looks like there is not a simple setting to setup the thing which I want to do(I dont know the jargon used for what I am trying to do, I'm dumb okay?!).&lt;/p&gt;

&lt;p&gt;Research tell me that I have to create a cloudfront distribution. Let's do it.&lt;/p&gt;

&lt;p&gt;Waiting... waiting... waiting ... AHA Deployed!!&lt;/p&gt;

&lt;p&gt;Now I have to create something in Route53 from aws, which shall enable me to link my domain name and the hosted content in cloudfront.&lt;/p&gt;

&lt;p&gt;My source tells me that it would need 48 hours to have the website deployed.&lt;/p&gt;

&lt;p&gt;So if everything works out, Ya'll should be able to see something on &lt;a href="https://mentorfix.org/"&gt;https://mentorfix.org/&lt;/a&gt; . Obviously nothing works at the moment, but I wish to work on in more eventually.&lt;/p&gt;

&lt;p&gt;Let me know in the comments if you find something that I should have done to lessen my time spent on deployments and I will try and do that. Or maybe, you can make that contribution to the org if you wish to. &lt;/p&gt;

&lt;p&gt;Thank you so much for bearing with me, I know this blogpost is not as conclusive as the last one. But I will improve eventually.&lt;/p&gt;

&lt;p&gt;Until then..&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/l44Qdv43pGxw9giuA/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/l44Qdv43pGxw9giuA/giphy.gif" alt="kachow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PS: Fave is hiring, checkout &lt;a href="//careers.myfave.com"&gt;our career page&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;PPS: This &lt;a href="https://benjamincongdon.me/blog/2017/06/13/How-to-Deploy-a-Secure-Static-Site-to-AWS-with-S3-and-CloudFront/#step-4-configure-route53-to-route-traffic-from-our-custom-domain"&gt;link&lt;/a&gt; was a massive help, do check it out.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Testing issues as usual...</title>
      <dc:creator>Abhishek Prasad</dc:creator>
      <pubDate>Sat, 03 Aug 2019 13:11:06 +0000</pubDate>
      <link>https://dev.to/abhishek71994/testing-issues-as-usual-pkm</link>
      <guid>https://dev.to/abhishek71994/testing-issues-as-usual-pkm</guid>
      <description>&lt;p&gt;Having gone through setting up CI/CD for my schmol project, I realized that TDD is a pretty darn cool thing to have and it helps to automate stuff and also gives confidence not just to the coder but also to the reviewer.&lt;/p&gt;

&lt;p&gt;Having said that, I had implemented Jest and Enzyme to set up the tests. Now as a developer I am really interested in knowing more about testing. The company which I work for, Fave (We are hiring, link at the end of this post), focuses a lot of TDD and I see where and why is it needed.&lt;/p&gt;

&lt;p&gt;So obviously I had to go with the most popular option, Jest paired with enzyme. I still don't have any idea why did I go with that. But hey, after a damn long setup...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ofZOhzDQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/en98uykzvx1r1xnm92l4.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ofZOhzDQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/en98uykzvx1r1xnm92l4.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GOSH DARN AWESOME! 😱&lt;/p&gt;

&lt;p&gt;I was really happy until I refactored my code right now. And ran into this bad boy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zae-cpX1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/olizuza30t2jxj7p058m.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zae-cpX1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/olizuza30t2jxj7p058m.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/CDJo4EgHwbaPS/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/CDJo4EgHwbaPS/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So apparently Jest cant deal with importing images.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;When you import image files, Jest tries to interpret the binary codes of the images as .js, hence runs into errors.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Did some research, found out that there is something called &lt;code&gt;moduleNameMapper&lt;/code&gt;, that needs to be configured for things to work out.&lt;/p&gt;

&lt;p&gt;ummmmmmmmmmm looks like too much work... NETFLIX BREAK!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/l0HlL96SusHggSo6s/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/l0HlL96SusHggSo6s/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2 episodes later&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Alright! Let's do this!&lt;/p&gt;

&lt;p&gt;As I already had a &lt;code&gt;jest.config.json&lt;/code&gt; for setting up polyfills for tests and also to set up the enzyme adapter(I don't know why, but it wasn't working otherwise).&lt;/p&gt;

&lt;p&gt;All I had to do was add&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"moduleNameMapper": {
        "\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "&amp;lt;rootDir&amp;gt;/__mocks__/fileMock.js",
        "\\.(css|less)$": "&amp;lt;rootDir&amp;gt;/mocks/fileMock.js"
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now comes to mocking the files. Created them with a simple &lt;br&gt;
&lt;code&gt;exports default '';&lt;/code&gt;... &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---35S9lH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ytxe709w8g1bubcp7at1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---35S9lH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ytxe709w8g1bubcp7at1.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JwodXnMq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/http://giphygifs.s3.amazonaws.com/media/i8tV2kJB8Gig8/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JwodXnMq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/http://giphygifs.s3.amazonaws.com/media/i8tV2kJB8Gig8/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"moduleNameMapper": {
        "\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "&amp;lt;rootDir&amp;gt;/__mocks__/fileMock.js",
        "\\.(css|scss)$": "&amp;lt;rootDir&amp;gt;//__mocks__/fileMock.js"
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Freakin SCSS... Alright, let's try it again.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k3sb2iJj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9e80q7snlwkjtt5pkxvt.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k3sb2iJj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9e80q7snlwkjtt5pkxvt.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This feeling right here...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/nDMyoNRkCesJdZAuuL/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/nDMyoNRkCesJdZAuuL/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Is why I am a developer.&lt;/p&gt;

&lt;p&gt;You can check out my itsy bitsy org at &lt;a href="https://github.com/WrippleFoss/"&gt;https://github.com/WrippleFoss/&lt;/a&gt;&lt;br&gt;
We are trying to build an open-source platform for something 😉 &lt;em&gt;secret&lt;/em&gt;.&lt;br&gt;
You can also join the discord channel using this &lt;a href="https://discord.gg/7TahF4D"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Fave is hiring, apply to &lt;a href="https://careers.myfave.com/"&gt;https://careers.myfave.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Until next time...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/nqYXNf3aK6EvK/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/nqYXNf3aK6EvK/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
