Coder Social home page Coder Social logo

boilerplate-react-app-firebase's Introduction

SETUP

  1. Initiate a new project with yarn init
  2. Replicate the file structure above
  3. Ensure that the following are installed globally
  4. No add dependencies: -yarn add [email protected] [email protected]
  5. Command to set up babel to watch for file changes and to build to public/scripts/app.js
    • babel src/app.js --out-file=public/scripts/app.js --presets=env,react --watch
  6. Now run command to launch live-server live-server public

If install dependencies locally then use this script:

  "scripts":{
    "serve": "live-server public/",
    "build": "babel src/app.js --out-file=public/scripts/app.js --presets=env,react --watch"
  }

Webpack

BASIC SETUP

  const path = require('path');
  module.exports = {
    entry: './src/app.js',   //the main file we want to start converting
    output: {
      path: path.join(__dirname, 'public'),  //dirname gives us the directory of any machine and then join adds the path we want to connect to
      filename: 'bundle.js'  //this can be named anything as long as it matches the script in public/index.html 
    }
  };

ADDING BABEL TO WEBPACK

To enable babel webpack we need to add dependencies "babel-core": "6.25.0", "babel-loader": "7.1.1"

Also need to add a new file: .babelrc to state the presets to use

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

This is the main webpack config file now with webpack-loader

const path = require('path');
module.exports = {
  entry: './src/app.js',
  output: {
    path: path.join(__dirname, 'public'),
    filename: 'bundle.js'
  },
  module:{
    rules:[{
      loader: 'babel-loader',
      test: /\.js$/,    //tell webpack to look for anything that ends with .js (using regex)
      exclude: /node_modules/ //exclude anything in node_modules
    }]
  }
};

Dev Tools in Webpack

To make it easy to track the source of errors and logs, add this line: devtool:'cheap-module-eval-source-map'

boilerplate-react-app-firebase's People

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.