Skip to content

Commit cbafbe0

Browse files
author
Nicolas BuraBure Fernandez
committed
base
0 parents  commit cbafbe0

File tree

11 files changed

+232
-0
lines changed

11 files changed

+232
-0
lines changed

.babelrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"stage": 2,
3+
"env": {
4+
"development": {
5+
"plugins": ["react-transform"],
6+
"extra": {
7+
"react-transform": {
8+
"transforms": [{
9+
"transform": "react-transform-hmr",
10+
"imports": ["react"],
11+
"locals": ["module"]
12+
}, {
13+
"transform": "react-transform-catch-errors",
14+
"imports": ["react", "redbox-react"]
15+
}]
16+
}
17+
}
18+
}
19+
}
20+
}

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tmp/*
2+
public/*

.eslintrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"parser": "babel-eslint",
3+
"ecmaFeatures": {
4+
"blockBindings": true,
5+
"forOf": true,
6+
"arrowFunctions": true,
7+
"jsx": true,
8+
"modules": true,
9+
"classes": true
10+
},
11+
"extends": "airbnb",
12+
"rules": {
13+
"indent": [2, 2],
14+
"comma-dangle" : [0],
15+
"func-names": [0],
16+
"key-spacing": [2, { "align": "colon" }],
17+
},
18+
"env": {
19+
"browser": true,
20+
"node": true,
21+
"es6": true,
22+
"amd": true,
23+
"mocha": true
24+
},
25+
"plugins": [
26+
"react"
27+
]
28+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules
3+
npm-debug.log
4+
dist

app/client/index.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import { App } from '../containers/App.jsx';
4+
5+
ReactDOM.render(<App />, document.getElementById('root'));

app/containers/App.jsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { Component } from 'react';
2+
3+
export const NICE = 'pink';
4+
export const SUPER_NICE = 'darkred';
5+
6+
class Counter extends Component {
7+
constructor(props) {
8+
super(props);
9+
this.state = { counter: 0 };
10+
this.interval = setInterval(() => this.tick(), 1000);
11+
}
12+
13+
componentWillUnmount() {
14+
clearInterval(this.interval);
15+
}
16+
17+
tick() {
18+
this.setState({
19+
counter: this.state.counter + this.props.increment
20+
});
21+
}
22+
23+
render() {
24+
return (
25+
<h1 style={{ color: this.props.color }}>
26+
Counter ({this.props.increment}): {this.state.counter}
27+
</h1>
28+
);
29+
}
30+
}
31+
32+
export const App = () => {
33+
return (
34+
<div>
35+
<Counter increment={1} color={NICE} />
36+
<Counter increment={5} color={SUPER_NICE} />
37+
</div>
38+
);
39+
};

devServer.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const path = require('path');
2+
const express = require('express');
3+
const webpack = require('webpack');
4+
const config = require('./webpack.config.dev');
5+
6+
const app = express();
7+
const 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.use(express.static('public'));
17+
18+
app.get('/', function(req, res) {
19+
res.sendFile(path.join(__dirname, 'public', 'index.html'));
20+
});
21+
22+
app.listen(3000, 'localhost', function(err) {
23+
if (err) {
24+
console.log(err);
25+
return;
26+
}
27+
28+
console.log('Listening at http://localhost:3000');
29+
});

package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "dx-react-webpack",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"build:webpack": "NODE_ENV=production webpack --config webpack.config.prod.js",
8+
"build": "npm run build:webpack",
9+
"start": "node devServer.js",
10+
"lint": "eslint . --ext .js --ext .jsx"
11+
},
12+
"author": "Nicolas @elBurabure Fernandez",
13+
"license": "MIT",
14+
"devDependencies": {
15+
"babel-core": "^5.8.29",
16+
"babel-eslint": "^4.1.3",
17+
"babel-loader": "^5.3.2",
18+
"babel-plugin-react-transform": "^1.1.1",
19+
"eslint": "^1.7.3",
20+
"eslint-config-airbnb": "^0.1.0",
21+
"eslint-plugin-react": "^3.6.3",
22+
"express": "^4.13.3",
23+
"react-transform-catch-errors": "^1.0.0",
24+
"react-transform-hmr": "^1.0.0",
25+
"redbox-react": "^1.1.1",
26+
"webpack": "^1.12.2",
27+
"webpack-dev-middleware": "^1.2.0",
28+
"webpack-hot-middleware": "^2.4.1"
29+
},
30+
"dependencies": {
31+
"react": "^0.14.0",
32+
"react-dom": "^0.14.0"
33+
}
34+
}

public/index.html

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

webpack.config.dev.js

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

0 commit comments

Comments
 (0)