Last active
March 5, 2016 16:17
React-Webpack Quick Start
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<title>React</title> | |
<body> | |
<div id="App"></div> | |
<script src="bundle.js"></script> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
// try moving this component to a separate file! | |
let App = React.createClass({ | |
render() { | |
return ( | |
<div> | |
<h1>App</h1> | |
<p>lorem ipsum test</p> | |
</div> | |
); | |
} | |
}); | |
ReactDOM.render(<App/>, document.getElementById('App')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "react-webpack-quick-start", | |
"scripts": { | |
"dev": "webpack-dev-server" | |
}, | |
"dependencies": { | |
"react": "^0.14.0", | |
"react-dom": "^0.14.0" | |
}, | |
"devDependencies": { | |
"babel-core": "^5.8.21", | |
"babel-loader": "^5.3.2", | |
"react-hot-loader": "^1.2.8", | |
"webpack": "^1.11.0", | |
"webpack-dev-server": "^1.10.1" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var path = require('path'); | |
var webpack = require('webpack'); | |
module.exports = { | |
context: __dirname, | |
//devtool: 'source-map', // @see http://webpack.github.io/docs/configuration.html#devtool | |
devServer: { | |
hot: true, // set this to false to disable react-hot-loader | |
inline: true | |
//contentBase: 'dist', | |
//host: process.env.IP, | |
//port: process.env.PORT | |
}, | |
entry: [ | |
'webpack/hot/only-dev-server', | |
'./main' | |
], | |
output: { | |
path: path.join(__dirname, 'dist'), | |
filename: 'bundle.js' | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.(js|jsx)$/, | |
loaders: ['react-hot', 'babel'], | |
exclude: /node_modules/ | |
} | |
] | |
}, | |
plugins: [ | |
//new webpack.optimize.UglifyJsPlugin({minimize: true}) | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.NoErrorsPlugin() | |
], | |
resolve: { | |
extensions: ['', '.js', '.jsx'] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Getting Started
npm install
npm run dev