Skip to content

Instantly share code, notes, and snippets.

@roylee0704
Last active November 30, 2015 08:49
Show Gist options
  • Save roylee0704/ecda88a3a0f8af63205a to your computer and use it in GitHub Desktop.
Save roylee0704/ecda88a3a0f8af63205a to your computer and use it in GitHub Desktop.
React Fundamental Setup

#React Fundamental Setup

##1.0 Global - One Time Job

npm install babel webpack webpack-dev-server -g

##2.0 Each React Project Setup

###2.1 Library

$ npm init
$ npm install react react-dom --save-dev
$ npm install babel-loader babel-core babel-preset-es2015 babel-preset-react --save-dev

###2.2 Repo Scalfolding

$ touch index.html App.js entry.js webpack.config.js

##3.0 Configurations

###3.1 webpack.config.js

This is the file that going to compile all of our .js, .jsx, boils down to single bundle.js and as well going to launch our development server

//export an object
module.exports = {
  entry: './entry.js',
  output: {
    path: './',
    filename: 'bundle.js'
  },
  //arguments for devserver
  devServer: {
    inline: true, //watch
    port:3333
  },
  module: {
    loaders: [
      {
        test: /.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react']
        }
      }
    ]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment