GithubHelp home page GithubHelp logo

ptzagk / react-hooks-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from reeganexe/react-hooks-boilerplate

0.0 2.0 0.0 81 KB

React Hooks Boilerplate with Hot Reload ๐Ÿ”ฅ

JavaScript 100.00%

react-hooks-boilerplate's Introduction

React Hooks Boilerplate with Hot Reload

react-hot-loader is now compatible with React Hooks APIs.

This boilerplate could help you start to play React Hooks APIs with Hot Reload.

npm install
npm start

Check it out: http://localhost:8080

Lint & Build

npm run lint
npm run build

Begin from scratch

Init project

Create a new directory then

npm init -y

Install dependencies

npm install react@latest react-dom@latest react-hot-loader

Install development dependencies

Babel

npm install @babel/core @babel/preset-env @babel/preset-react babel-loader --save-dev

Webpack

npm install webpack webpack-cli webpack-dev-server html-webpack-plugin --save-dev

ESLint Airbnb

npx install-peerdeps --dev eslint-config-airbnb
npm install babel-eslint --save-dev

Cross-env

npm install cross-env --save-dev

Set up

Babel config

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react"
  ],
  "plugins": [
    "react-hot-loader/babel"
  ]
}

ESLint config

{
  "parser": "babel-eslint",
  "extends": ["airbnb"],
  "env": {
    "browser": true
  },
  "rules": {
    "arrow-parens": "off",
    "comma-dangle": ["error", "never"],
    "no-confusing-arrow": "off",
    "no-unused-expressions": "off",
    "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
    "react/jsx-one-expression-per-line": "off"
  },
  "plugins": [
    "react"
  ]
}

webpack.config.js

const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const { env } = process;

const options = {
  mode: env.NODE_ENV,
  entry: './src/index.js',
  output: {
    filename: '[name].js'
  },
  module: {
    rules: [
      { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }
    ]
  },
  plugins: [
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(env.NODE_ENV) }),
    new HtmlWebpackPlugin()
  ],
  devServer: {
    hot: true
  },
  devtool: env.NODE_ENV === 'development' ? 'cheap-module-eval-source-map' : undefined
};

module.exports = options;

NPM Scripts

{
  "scripts": {
    "start": "cross-env NODE_ENV=development webpack-dev-server --hot",
    "build": "cross-env NODE_ENV=production webpack",
    "lint": "eslint ./src"
  },
}

Enjoy ๐ŸŽ…๐ŸŽ„๐Ÿ”ฅ

react-hooks-boilerplate's People

Contributors

reeganexe avatar

Watchers

 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.