Clone this gist and run npm install
.
The best way is to run webpack -w
and then just
open index.html
in your favorite browser.
/node_modules | |
/bundle.js | |
/bundle.js.map |
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'] | |
} | |
}] | |
} | |
}; |