Skip to content

Instantly share code, notes, and snippets.

@christiearcus
Last active July 24, 2016 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christiearcus/d5e1baeb8c8197050d8047441116695d to your computer and use it in GitHub Desktop.
Save christiearcus/d5e1baeb8c8197050d8047441116695d to your computer and use it in GitHub Desktop.
Setup react build tools

Do a blog post on this, as it’s so annoying to re-remember!

1 Set up libraries & dependencies

Set up blank project folder:

  • npm init (and follow the prompts)
  • npm install react react-dom —save
  • npm install webpack webpack-dev-server -g
  • npm install babel -g
  • npm install babel-loader babel-core babel-preset-es2015 babel-preset-react

2 Configuration

touch

  • index.html
  • main.js (entry point in to our app)
  • webpack.config.js
  • Your app files (e.g. App.js)

3 in webpack.config.js

module.exports = {
  entry: './main.js',
  output: {
    path: './',
    filename: ‘bundle.js'
  },
  devServer: {
    inline: true,
    port: 3333
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'react']
        }
      }
    ]
  }
}

4 in package.json

Write script:

“start”: “webpack-dev-server”.

then just run webpack and you’ll have a dev-server up and running.

5 A bit about module writing?

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