Skip to content

Instantly share code, notes, and snippets.

@teamon
Last active January 8, 2016 15:08
Show Gist options
  • Save teamon/5a086cd82e9a1de8997b to your computer and use it in GitHub Desktop.
Save teamon/5a086cd82e9a1de8997b to your computer and use it in GitHub Desktop.
react + webpack + babel (es2015 + jsx + stage-0) starter
/node_modules
/bundle.js
/bundle.js.map

react + webpack + babel (es2015 + jsx + stage-0) starter

Instalation

Clone this gist and run npm install.

Usage

The best way is to run webpack -w and then just open index.html in your favorite browser.

body {
padding: 10px;
background: #fff;
}
* {
box-sizing: border-box;
font-family: Menlo, monospace;
font-size: 12px;
}
import React from "react"
import ReactDOM from "react-dom"
class App extends React.Component {
render(){
return <div>Hello World</div>
}
}
ReactDOM.render(<App/>, document.getElementById("main"))
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="app.css">
</head>
<body>
<div id="main"></div>
<script type="text/javascript" src="bundle.js"></script>
</body>
</html>
{
"dependencies": {
"react": "^0.14.6",
"react-dom": "^0.14.6"
},
"devDependencies": {
"babel-core": "^6.4.0",
"babel-loader": "^6.2.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.4.0",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"webpack": "^1.12.10"
}
}
var webpack = require('webpack');
module.exports = {
entry: "./app.js",
output: {
filename: "bundle.js"
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
presets: ["es2015", "stage-0", "react"],
plugins: ['transform-runtime', 'transform-decorators-legacy']
}
}]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment