Skip to content

Commit 10efd44

Browse files
committed
Added boilerplate code
1 parent 191c89b commit 10efd44

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed

devServer.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var path = require('path');
2+
var express = require('express');
3+
var webpack = require('webpack');
4+
var config = require('./webpack.config.dev');
5+
6+
var app = express();
7+
var compiler = webpack(config);
8+
9+
app.use(require('webpack-dev-middleware')(compiler, {
10+
noInfo: true,
11+
publicPath: config.output.publicPath
12+
}));
13+
14+
app.use(require('webpack-hot-middleware')(compiler));
15+
16+
app.get('*', function(req, res) {
17+
res.sendFile(path.join(__dirname, 'index.html'));
18+
});
19+
20+
app.listen(3000, 'localhost', function(err) {
21+
if (err) {
22+
console.log(err);
23+
return;
24+
}
25+
26+
console.log('Listening at http://localhost:3000');
27+
});

index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>React Transform Boilerplate</title>
5+
</head>
6+
<body>
7+
<div id='root'>
8+
</div>
9+
<script src="/static/bundle.js"></script>
10+
</body>
11+
</html>

package.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "react-transform-boilerplate",
3+
"version": "1.0.0",
4+
"description": "A new Webpack boilerplate with hot reloading React components, and error handling on module and component level.",
5+
"scripts": {
6+
"clean": "rimraf dist",
7+
"build:webpack": "NODE_ENV=production webpack --config webpack.config.prod.js",
8+
"build": "npm run clean && npm run build:webpack",
9+
"start": "node devServer.js",
10+
"lint": "eslint src"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/gaearon/react-transform-boilerplate.git"
15+
},
16+
"keywords": [
17+
"react",
18+
"reactjs",
19+
"boilerplate",
20+
"hot",
21+
"reload",
22+
"hmr",
23+
"live",
24+
"edit",
25+
"webpack",
26+
"babel",
27+
"react-transform"
28+
],
29+
"author": "Dan Abramov <[email protected]> (http://github.com/gaearon)",
30+
"license": "CC0-1.0",
31+
"bugs": {
32+
"url": "https://github.com/gaearon/react-transform-boilerplate/issues"
33+
},
34+
"homepage": "https://github.com/gaearon/react-transform-boilerplate",
35+
"devDependencies": {
36+
"babel-core": "^5.4.7",
37+
"babel-eslint": "^3.1.9",
38+
"babel-loader": "^5.1.2",
39+
"babel-plugin-react-transform": "^1.1.1",
40+
"eslint": "^1.3.1",
41+
"eslint-plugin-react": "^2.3.0",
42+
"express": "^4.13.3",
43+
"react-transform-catch-errors": "^1.0.0",
44+
"react-transform-hmr": "^1.0.0",
45+
"redbox-react": "^1.0.1",
46+
"rimraf": "^2.4.3",
47+
"webpack": "^1.9.6",
48+
"webpack-dev-middleware": "^1.2.0",
49+
"webpack-hot-middleware": "^2.0.0"
50+
},
51+
"dependencies": {
52+
"react": "^0.13.0"
53+
}
54+
}

webpack.config.dev.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var path = require('path');
2+
var webpack = require('webpack');
3+
4+
module.exports = {
5+
devtool: 'eval',
6+
entry: [
7+
'webpack-hot-middleware/client',
8+
'./src/index'
9+
],
10+
output: {
11+
path: path.join(__dirname, 'dist'),
12+
filename: 'bundle.js',
13+
publicPath: '/static/'
14+
},
15+
plugins: [
16+
new webpack.HotModuleReplacementPlugin(),
17+
new webpack.NoErrorsPlugin()
18+
],
19+
module: {
20+
loaders: [{
21+
test: /\.js$/,
22+
loaders: ['babel'],
23+
include: path.join(__dirname, 'src')
24+
}]
25+
}
26+
};

webpack.config.prod.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var path = require('path');
2+
var webpack = require('webpack');
3+
4+
module.exports = {
5+
devtool: 'source-map',
6+
entry: [
7+
'./src/index'
8+
],
9+
output: {
10+
path: path.join(__dirname, 'dist'),
11+
filename: 'bundle.js',
12+
publicPath: '/static/'
13+
},
14+
plugins: [
15+
new webpack.optimize.OccurenceOrderPlugin(),
16+
new webpack.DefinePlugin({
17+
'process.env': {
18+
'NODE_ENV': JSON.stringify('production')
19+
}
20+
}),
21+
new webpack.optimize.UglifyJsPlugin({
22+
compressor: {
23+
warnings: false
24+
}
25+
})
26+
],
27+
module: {
28+
loaders: [{
29+
test: /\.js$/,
30+
loaders: ['babel'],
31+
include: path.join(__dirname, 'src')
32+
}]
33+
}
34+
};

0 commit comments

Comments
 (0)