Skip to content

Instantly share code, notes, and snippets.

@joemaddalone
Created December 15, 2015 00:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save joemaddalone/1417d7f8524e0fd3bb5f to your computer and use it in GitHub Desktop.
Save joemaddalone/1417d7f8524e0fd3bb5f to your computer and use it in GitHub Desktop.

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Setup</title>
</head>
<body>
  <div id="app"></div>
  <script src="index.js"></script>
</body>
</html>

package.json

{
  "name": "es6-react-setup",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
      "start": "webpack-dev-server"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
      "babel-core": "^6.2.1",
      "babel-loader": "^6.2.0",
      "babel-preset-es2015": "^6.1.18",
      "babel-preset-react": "^6.1.18",
      "react": "^0.14.3",
      "react-dom": "^0.14.3"
  },
  "description": "Setup files for React in ES6 lessons"
}

webpack.config.js

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

App.js

import React from 'react';
class App extends React.Component {
  render(){
    return <div>Hi</div>
  }
}

export default App

main.js

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />, document.getElementById('app'))
@efmanu
Copy link

efmanu commented Sep 19, 2016

Thanks a lot

@pavlosvos
Copy link

Replaced my files with yours but still "npm start" throws a error... fu$%&/()=

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