├── .gitignore ├── .babelrc ├── .eslintrc ├── src └── app.js ├── index.html ├── server.js ├── README.md ├── LICENSE ├── webpack.config.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .DS_Store -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-0", "react"] 3 | } -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "comma-dangle": [2, "never"] 4 | }, 5 | "extends": "airbnb" 6 | } -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from 'react-dom'; 3 | 4 | const App = () =>

Hello from React Boilerplate!

; 5 | 6 | render(, document.getElementById('root')); 7 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Setting up your dev environment 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | var path = require('path'); 4 | var express = require('express'); 5 | var webpack = require('webpack'); 6 | var config = require('./webpack.config'); 7 | 8 | var app = express(); 9 | var compiler = webpack(config); 10 | 11 | app.use(require('webpack-dev-middleware')(compiler, { 12 | noInfo: true, 13 | publicPath: config.output.publicPath 14 | })); 15 | 16 | app.use(require('webpack-hot-middleware')(compiler)); 17 | 18 | app.get('*', function(req, res) { 19 | res.sendFile(path.join(__dirname, '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 | }); 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | React Boilerplate 2 | === 3 | 4 | I've done it so many times manually that now is the time to just have a repo with the initial setup. 5 | 6 | ### Setup includes 7 | 8 | - React 9 | 10 | - Babel 6 (presets: `es2015`, `react`, `stage-0`) 11 | 12 | - Webpack 13 | 14 | - Eslint 15 | 16 | - Hot reloading (HMR) 17 | 18 | ### Get started 19 | 20 | 1. Clone and navigate to the repo directory 21 | 22 | 2. Install dependencies: `npm install` 23 | 24 | 3. Run project: `npm start` 25 | 26 | 4. Navigate to: http://127.0.0.1:3000 in your browser 27 | 28 | 5. (For linting) Run: `npm run lint` 29 | 30 | ### Contribute 31 | 32 | If you spot any bugs or if you thing I should improve something, please file an issue or send a PR with suggested changes. 33 | 34 | ### License 35 | 36 | MIT -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Mateusz Zatorski 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. -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-var */ 2 | 3 | var path = require('path'); 4 | var webpack = require('webpack'); 5 | 6 | module.exports = { 7 | devtool: 'eval', 8 | entry: [ 9 | 'webpack-hot-middleware/client', 10 | 'babel-polyfill', 11 | './src/app' 12 | ], 13 | output: { 14 | path: path.join(__dirname, 'dist'), 15 | filename: 'bundle.js', 16 | publicPath: '/static/' 17 | }, 18 | plugins: [ 19 | new webpack.HotModuleReplacementPlugin(), 20 | new webpack.NoErrorsPlugin() 21 | ], 22 | module: { 23 | loaders: [{ 24 | test: /\.js$/, 25 | loader: 'babel', 26 | query: { 27 | plugins: [ 28 | [ 29 | 'react-transform', { 30 | transforms: [{ 31 | transform: 'react-transform-hmr', 32 | imports: ['react'], 33 | locals: ['module'] 34 | }, { 35 | transform: 'react-transform-catch-errors', 36 | imports: ['react', 'redbox-react'] 37 | }] 38 | } 39 | ] 40 | ] 41 | }, 42 | include: path.join(__dirname, 'src') 43 | }] 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-boilerplate", 3 | "version": "1.0.0", 4 | "description": "Boilerplate for React app.", 5 | "main": "server.js", 6 | "scripts": { 7 | "start": "node server.js", 8 | "lint": "eslint src" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/knowbody/react-boilerplate" 13 | }, 14 | "author": "Mateusz Zatorski (https://github.com/knowbody)", 15 | "license": "MIT", 16 | "bugs": { 17 | "url": "https://github.com/knowbody/react-boilerplate/issues" 18 | }, 19 | "homepage": "https://github.com/knowbody/react-boilerplate#readme", 20 | "devDependencies": { 21 | "babel-core": "^6.7.2", 22 | "babel-eslint": "^5.0.0", 23 | "babel-loader": "^6.2.4", 24 | "babel-plugin-react-transform": "^2.0.2", 25 | "babel-polyfill": "^6.7.2", 26 | "babel-preset-es2015": "^6.6.0", 27 | "babel-preset-react": "^6.5.0", 28 | "babel-preset-stage-0": "^6.5.0", 29 | "eslint": "^2.4.0", 30 | "eslint-config-airbnb": "^6.1.0", 31 | "eslint-plugin-react": "^4.2.3", 32 | "express": "^4.13.4", 33 | "json-loader": "^0.5.4", 34 | "react-transform-catch-errors": "^1.0.2", 35 | "react-transform-hmr": "^1.0.4", 36 | "redbox-react": "^1.2.2", 37 | "webpack": "^1.12.14", 38 | "webpack-dev-middleware": "^1.5.1", 39 | "webpack-hot-middleware": "^2.10.0" 40 | }, 41 | "dependencies": { 42 | "react": "^15.0.1", 43 | "react-dom": "^15.0.1" 44 | } 45 | } 46 | --------------------------------------------------------------------------------