Skip to content

Commit d161427

Browse files
committed
Commiting all sample code
1 parent 8d13096 commit d161427

File tree

121 files changed

+4755
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+4755
-2
lines changed

.gitignore

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

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
# sample-code
2-
Sample code for chapters
1+
React App Boilerplate
2+
=====================
3+
4+
Sample codes used in the Pro React book, organized per chapter.
5+
6+
### Usage
7+
8+
All chapter folders contain individual projects with individual package.json and webpack configurations. To run anyone of them use:
9+
10+
```
11+
npm install
12+
npm start
13+
```
14+
15+
Open http://localhost:8080 in your browser.

chapter 1/groceryList/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Cassio Zen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

chapter 1/groceryList/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Grocery List
2+
============
3+
4+
**Install**
5+
```
6+
npm install
7+
```
8+
9+
**Start the application in development mode**
10+
```
11+
npm start
12+
```
13+
14+
Open http://localhost:8080 in your browser.

chapter 1/groceryList/app/App.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chapter 1/groceryList/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "react-app-boilerplate",
3+
"version": "0.1.3",
4+
"description": "React application boilerplate",
5+
"author": "Cássio Zen",
6+
"license": "ISC",
7+
"scripts": {
8+
"start": "node_modules/.bin/webpack-dev-server --progress",
9+
"build": "NODE_ENV=production node_modules/.bin/webpack -p --progress --colors"
10+
},
11+
"devDependencies": {
12+
"babel-core": "~6.0.*",
13+
"babel-loader": "~6.0.*",
14+
"babel-preset-es2015": "~6.0.*",
15+
"babel-preset-react": "~6.0.*",
16+
"webpack": "~1.12.*",
17+
"webpack-dev-server": "~1.12.*"
18+
},
19+
"dependencies": {
20+
"react": "~0.14.*",
21+
"react-dom": "~0.14.*"
22+
}
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title></title>
6+
<link rel="stylesheet" href="styles.css">
7+
</head>
8+
<body>
9+
<div id='root'>
10+
</div>
11+
<script src="bundle.js"></script>
12+
</body>
13+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
body {
2+
font: 16px/1 sans-serif;
3+
}
4+
#root {
5+
height: 100%;
6+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var webpack = require('webpack');
2+
3+
/*
4+
* Default webpack configuration for development
5+
*/
6+
var config = {
7+
devtool: 'eval-source-map',
8+
entry: __dirname + "/app/App.js",
9+
output: {
10+
path: __dirname + "/public",
11+
filename: "bundle.js"
12+
},
13+
module: {
14+
loaders: [{
15+
test: /\.jsx?$/,
16+
exclude: /node_modules/,
17+
loader: 'babel',
18+
query: {
19+
presets: ['es2015','react']
20+
}
21+
}]
22+
},
23+
devServer: {
24+
contentBase: "./public",
25+
colors: true,
26+
historyApiFallback: true,
27+
inline: true
28+
},
29+
}
30+
31+
/*
32+
* If bundling for production, optimize output
33+
*/
34+
if (process.env.NODE_ENV === 'production') {
35+
config.devtool = false;
36+
config.plugins = [
37+
new webpack.optimize.OccurenceOrderPlugin(),
38+
new webpack.optimize.UglifyJsPlugin({comments: false}),
39+
new webpack.DefinePlugin({
40+
'process.env': {NODE_ENV: JSON.stringify('production')}
41+
})
42+
];
43+
};
44+
45+
module.exports = config;

chapter 2/JSX/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Cassio Zen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)