Skip to content

Instantly share code, notes, and snippets.

@marcusshepp
Last active September 28, 2016 14:09
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 marcusshepp/d00e0720ccf0b29a191befb275850bdd to your computer and use it in GitHub Desktop.
Save marcusshepp/d00e0720ccf0b29a191befb275850bdd to your computer and use it in GitHub Desktop.
setting up react and webpack dev server with hot module replacement

package.json

{
  "name": "todo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "./node_modules/.bin/webpack-dev-server --inline --hot",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel": "^6.5.2",
    "babel-core": "^6.14.0",
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-react": "^6.11.1",
    "file-loader": "^0.9.0",
    "react-hot-loader": "^1.3.0",
    "webpack": "^1.13.2",
    "webpack-dev-server": "^1.16.1"
  },
  "dependencies": {
    "react": "^15.3.2",
    "react-dom": "^15.3.2"
  }
}

webpack.config.js

var path = require('path');
module.exports = {

    entry: {
        javascript: path.join(__dirname, 'src/app.js'),
        html: path.join(__dirname, 'index.html')
    },
    output: {
        path: './',
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                loaders: ['babel?presets[]=react,presets[]=es2015'],
                exclude: /node_modules/,
            },
            {
                test: /\.html$/,
                loader: "file?name=[name].[ext]",
            }
        ]
    }
}

https://robots.thoughtbot.com/setting-up-webpack-for-react-and-hot-module-replacement

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