Code Monkey home page Code Monkey logo

react-dummy's Introduction

React for Dummy

Create your WEBPACK to React

Install npm in debian jessie

$ apt install curl apt-transport-https

$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash 

$ apt install -y nodejs

$ npm install --global npm@latest

Start the webpack

Init project of Nodejs

$ npm init -y

Install depends of development for webpack with React

$ npm i -D webpack webpack-dev-server babel-loader babel-cli babel-preset-es2015 babel-preset-react

Install React

$ npm i -S react react-dom

Create file of babel .babelrc with the following content:

{
  "presets": [
    "es2015",
    "react"
  ]
}

Create the file to webpack webpack.config:

const path = require('path');

module.exports = {

  resolve: {
    extensions: ['.js', '.jsx']
  },

  context: __dirname,

  entry: {
    app: [path.resolve(__dirname, 'src', 'index.jsx')]
  },

  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'bundle.js',
    publicPath: path.resolve(__dirname, 'build')
  },
 
  devServer: {
    host: '0.0.0.0',
    port: 8080,
    inline: true
  },

  /* Apartado importante de webpack, 
  ** el que realiza las transformaciones
  */
  module: {
    loaders: [
      {
        test: /(\.js|.jsx)$/,
        include: path.resolve(__dirname),
        exclude: path.resolve(__dirname, 'node_modules'),
        loader: 'babel-loader',
        
        query: {
          presets: ['es2015'],
        }

      }
    ]
  }

}

Now add scripts to the file package.json:

"scripts": {
    "build": "webpack --colors",
    "serve": "webpack-dev-server --progress --colors",
    "start": "npm run build && npm run serve"
  },

Create folder build with the file index.html

<!DOCTYPE html>
<html>
<head>
	<title> React Sabe</title>
</head>
<body>
	<div id="root"> </div>
</body>
</html>

Create folder src with the file index.jsx:

import React from 'react'
import ReactDOM from 'react-dom'

class App extends React.Component {
  render () {
    return <h1> Hi React! </h1>
  }
}

ReactDOM.render(<App />, document.getElementById('root'))

And execute

$ npm start

react-dummy's People

Contributors

vpino avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.