<?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 Pranay Bhat on Medium]]></title>
        <description><![CDATA[Stories by Pranay Bhat on Medium]]></description>
        <link>https://medium.com/@pranaybhat199?source=rss-c07bfce88df9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MdgKM17Xp2GGwJPy</url>
            <title>Stories by Pranay Bhat on Medium</title>
            <link>https://medium.com/@pranaybhat199?source=rss-c07bfce88df9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:17:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pranaybhat199/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[“Webpack” was painful, “Parcel” was a relief but “create-react-app” blew my mind]]></title>
            <link>https://medium.com/@pranaybhat199/webpack-was-painful-parcel-was-a-relief-but-create-react-app-blew-my-mind-ce758edfdd29?source=rss-c07bfce88df9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce758edfdd29</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[create-react-app]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Pranay Bhat]]></dc:creator>
            <pubDate>Fri, 19 Oct 2018 13:47:52 GMT</pubDate>
            <atom:updated>2018-10-19T13:47:52.014Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/427/0*TQfcl-QmMRTdIgs9" /></figure><blockquote>If you have ever used <a href="https://webpack.js.org/"><em>Webpack</em></a> to configure your <em>React</em> Application and you notice some muscles developed on your index finger by continuously scrolling your <em>package.json</em> file, it’s a good time to switch to “<a href="https://github.com/facebook/create-react-app"><em>create-react-app</em></a><em>”</em> because…</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/0*7-k56WEfeXsrRqBn" /><figcaption><strong>finger muscles are useless</strong></figcaption></figure><p>The problem with <em>Webpack</em> is its configuration. It’s a nightmare. And I don’t know about you, but I don’t like nightmares. I prefer getting things done and not losing my mind in the process.</p><h3>What sets create-react-app apart</h3><p>Most other starter projects advise you to clone their <em>git</em> repository to get started. This has a few disadvantages:</p><ul><li>When the starter is updated, you don’t get those updates</li><li>Your project immediately has 50–100 dependencies to manage and keep updated</li></ul><p><em>create-react-app</em> works a bit differently. When you create-react-app, you get a project with a single dev dependency: the <em>react-scripts</em> package.</p><p>That <em>react-scripts</em> package has everything you need as a sub-dependency. This means a much smaller, cleaner, and easier-to-read project with less boilerplate.</p><h3>How is it good?</h3><p><em>create-react-app</em> is awesome for beginners because:</p><ul><li>get started with <em>React</em> immediately</li><li>no<em> web pack</em> config: one less thing to learn at first</li><li>no <em>babel</em> config</li><li>very few dependencies to manage</li><li>Built-in testing with <em>Jest</em></li><li>It provides runtime error messages in the browser</li><li>It provides a production-ready build of your app by running npm run build</li></ul><p>ES6 and some ES7, linting, tests, build, and even deploy to <em>GitHub</em> pages are all ready to go.</p><h3>Installing Create React App</h3><p>You create a new React project with the command</p><pre>#Using npx<br>npx create-react-app app-name</pre><pre>#Using npm init &lt;initializer&gt;<br>npm init react-app app-name</pre><pre>#Using yarn 0.25+<br>yarn create react-app app-name</pre><p>Now, if you look at the generated <em>package.json</em> file, you’ll only see three dependencies: react, react-dom, and react-scripts.</p><p>Inside your project directory, you can run several commands:</p><ul><li>npm start starts the development server and auto-reloads the page any time you make edits</li><li>npm run build bundles the app into static files for production</li><li>npm test starts the test runner and lets you test your app with Jest as you build it</li><li>npm run eject takes your app out of the create-react-app setup, which lets you customize your project configuration</li></ul><h3>How does it make our life easy?</h3><p>Well, let’s compare the package.json file for an application which was built from scratch and to the right is the one built using create-react-app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*FvH5Hs8fF_m6EtPBPVx1OQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/0*XcxPMxPDCSpln1qQ.gif" /></figure><p>I know it’s good to learn from your mistakes, but I think its even better to learn from others mistake, so here are a few instances when I completely lost track but I hope you can handle them after reading this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*xb1AhDii0Z6OFR5_Ngo5Yw.png" /></figure><p>When I first came across this error while writing a test case I got stuck real bad and had a tough time finding a way out of it. <a href="https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch">fetch</a>() method provides an easy, logical way to fetch resources asynchronously across the network. But, “<em>fetch”</em> is only understood by the browser environment, the test has no idea about it so we need to import “<a href="https://www.npmjs.com/package/isomorphic-fetch"><em>isomorphic-fetch</em></a>” to tackle this problem. But if you are using “<em>create-react-app” it </em>takes care of this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/0*F9cCWDixDRB7cebM" /><figcaption>Create-react-app the savior</figcaption></figure><h3>Built-in Testing with Jest</h3><p>The <a href="https://facebook.github.io/jest/"><em>Jest testing framework</em></a> is already configured when you use <em>“create-react-app”. </em>If you name your files using a filename convention (like .spec.js or .test.js), or if you place your test files inside a __tests__ folder, Jest will find those files and run your tests. Running the command npm test launches the test runner in watch mode. This means that every time you save a file, it will re-run your tests, similar to how npm start recompiles your code.</p><p>As we discussed before “create-react-app” makes all the build settings pre-configured, having said that we won’t be able to change the build setup as we don’t have access to <em>webpack.config</em> file. But there is a way to customize the setup by running the <em>eject</em> command…</p><h3>Ejecting</h3><p>Ejecting forks Create React App’s configuration and move it into your project. You can do that by running npm run ejectcommand. After the eject script runs, you’ll see a ‘config’ directory added to your project containing files like <em>webpack.config</em> for dev and production, and a <em>webpackDevServer.config</em> file. The single build dependency on package.json (react-scripts) will be removed from the project, and it will list each individual dependency. But once you eject you can’t go back.</p><h3>Everything (almost) comes with a downside</h3><p>It’s great to have this <em>eject</em> option, but if you do it you are left with all the disadvantages of any other starter pack, having too many dependencies. It doesn’t support CSS preprocessors, which infers to no LESS, SASS, CSS module support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/0*UMBUTHacn9sDsIm4" /></figure><h3>Conclusion</h3><p>This post covered all the cool features provided by create-react-app to make our lives easy. Although “<em>create-react-app</em>” is very helpful for beginners to develop react application, I would recommend developing react application from scratch at least once to get a good understanding of the react-scripts and how it actually works. There might be better alternatives depending on the type of application you’re developing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce758edfdd29" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>