<?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: Rakesh</title>
    <description>The latest articles on DEV Community by Rakesh (@rake5h1).</description>
    <link>https://dev.to/rake5h1</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%2F438643%2Ffc409c76-4761-499e-ac19-8430e7a7c843.png</url>
      <title>DEV Community: Rakesh</title>
      <link>https://dev.to/rake5h1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rake5h1"/>
    <language>en</language>
    <item>
      <title>Create-React-App from Scratch</title>
      <dc:creator>Rakesh</dc:creator>
      <pubDate>Thu, 23 Jul 2020 11:12:16 +0000</pubDate>
      <link>https://dev.to/rake5h1/create-react-app-from-scratch-4h68</link>
      <guid>https://dev.to/rake5h1/create-react-app-from-scratch-4h68</guid>
      <description>&lt;p&gt;Learn how to create Your First React App From Scratch.&lt;/p&gt;

&lt;p&gt;Building UI nowadays has become relatively easy as it used to be with the evolution of frontend javascript libraries and frameworks.&lt;strong&gt;React&lt;/strong&gt;, &lt;strong&gt;Angular&lt;/strong&gt;, &lt;strong&gt;Vue&lt;/strong&gt; are some of the prominent ones.React being the most widely used one.&lt;/p&gt;

&lt;p&gt;Getting started with react requires some configuration with &lt;strong&gt;webpack&lt;/strong&gt; and &lt;strong&gt;babel&lt;/strong&gt;.Thankfully developers of react have provided us with a boilerplate react app to get started instantly.To get started assuming you have one of &lt;strong&gt;npm&lt;/strong&gt; or &lt;strong&gt;yarn&lt;/strong&gt; package package manager.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app YOURAPPNAME

or

yarn create-react-app YOURAPPNAME

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



&lt;p&gt;This will create a biolerplate react app .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
npm start

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



&lt;p&gt;Visit localhost:3000 to start your react-app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But if you want to get started from scratch then this article is for you.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;How to get started with react from scratch?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;Create a folder of your desired name and inside that folder run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
npm init -y

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



&lt;p&gt;This will create a starter package.json file&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 :&lt;/strong&gt;Install necessary dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
npm i --save-dev webpack webpack-cli webpack-dev-server @babel/core babel-loader @babel/preset-env @babel/preset-react html-loader html-webpack-plugin inline-source-map


npm i --save react react-dom

or 


yarn add -D webpack webpack-cli webpack-dev-server @babel/core babel-loader @babel/preset-env @babel/preset-react html-loader html-webpack-plugin inline-source-map


yarn add react react-dom


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



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Create a &lt;em&gt;**webpack.config.js&lt;/em&gt;* file alongside package.json file.&lt;br&gt;
&lt;/p&gt;

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

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].js'
  },
  plugins: [new HtmlWebpackPlugin()],
 devServer: {
    contentBase: path.join(__dirname, 'dist'),
    compress: true,
    port: 3000,
    hot:true,
    liveReload:true
  },
devtool:'inline-source-map,
module: {
  rules: [
    {
      test: /\.js$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: 'babel-loader',
      },
{
      test: /\.html$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: 'html-loader',
      }
    }
  ]
}
};


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



&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Create a src directory and index.js ,App.js ,index.html inside it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Babel config.Create a .babelrc file in your root folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; {presets: ['@babel/preset-env',@babel/preset-react]}

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



&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt;create react app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
**index.js**

import React from 'react'
import {render} from 'react-dom'
import App from './App

render(&amp;lt;App/&amp;gt;,
documentElementbyId('root')
)


**App.js**

import React from 'react'

export default function App(){
return (&amp;lt;div&amp;gt;Hello&amp;lt;/div&amp;gt;)
}


**index.html**

&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;

&amp;lt;div id='root'&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;

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



&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Create scripts in package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
"start":"webpack-dev-server",
"build":"webpack --watch"


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



&lt;p&gt;All Set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; npm start 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For production build&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; npm run build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is the setup behind the create-react-app.&lt;/p&gt;

&lt;p&gt;Check out my website &lt;a href="https://c7ech.xyz"&gt;C7ech&lt;/a&gt; from more.&lt;/p&gt;

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