├── .babelrc
├── .eslintrc.js
├── .gitignore
├── LICENSE
├── README.md
├── app
├── components
│ ├── App.jsx
│ ├── Layout.jsx
│ ├── Logo.jsx
│ └── Piece.jsx
├── images
│ ├── Babel.png
│ ├── React.svg
│ ├── Sass.svg
│ └── Webpack.gif
├── index.html
├── index.jsx
├── lib.js
├── routes.jsx
└── styles
│ └── site.sass
├── firebase.json
├── package.json
├── server
├── entry.jsx
└── nginx.conf
├── webpack.config.js
├── webpack.server.js
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["es2015", { "modules": false }],
4 | "react",
5 | "stage-1"
6 | ],
7 | "env": {
8 | "development": {
9 | "presets": ["react-hmre"]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "parser": "babel-eslint",
3 | "extends": "airbnb",
4 | "rules": {
5 | "max-len": "off",
6 | "comma-dangle": "off",
7 | "no-else-return": "off",
8 | "no-mixed-operators": "off",
9 | "prefer-const": "warn",
10 | "prefer-template": "warn",
11 | "no-extend-native": "warn",
12 | "no-script-url": "warn",
13 | "no-use-before-define": "warn",
14 | "object-curly-spacing": ["error", "never"],
15 | "global-require": "warn",
16 | "jsx-a11y/img-has-alt": "warn",
17 | "react/prefer-stateless-function": "warn"
18 | },
19 | "plugins": [
20 | "react"
21 | ]
22 | };
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | temp
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016, Junfeng Liu
2 |
3 | Permission to use, copy, modify, and/or distribute this software for any
4 | purpose with or without fee is hereby granted, provided that the above
5 | copyright notice and this permission notice appear in all copies.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Webpack+React+Babel+Sass
2 | It took me several days to learn and assemble these pieces, so this boilerplate can save others time.
3 |
4 | DEPRECATED: Use [parcel-react-boilerplate](https://github.com/J-F-Liu/parcel-react-boilerplate.git) instead.
5 |
6 | # Usage
7 |
8 | 1. Install Node.js and Git
9 |
10 | 2. Download the repository
11 | ```
12 | git clone https://github.com/J-F-Liu/webpack-react-boilerplate.git
13 | cd webpack-react-boilerplate
14 | ```
15 | 3. Checkout `react-router` branch if you want to use react-router
16 |
17 | `git checkout react-router`
18 |
19 | 4. Install npm packages
20 |
21 | `npm install`
22 |
23 | 5. Start dev server
24 |
25 | `npm start`
26 |
27 | 6. Build website for production enviroment
28 |
29 | `npm run build`
30 |
31 | View [online demo](http://j-f-liu.github.io/webpack-react-boilerplate/).
32 | View [online demo with react-router](https://webpack-react-boiler.firebaseapp.com/).
33 |
34 | # Trouble shooting
35 | ```
36 | ERROR in ./~/css-loader!./~/sass-loader?indentedSyntax=true!./app/styles/site.sass
37 | Module build failed: Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (51)
38 | ```
39 | or
40 | ```
41 | ERROR in ./~/css-loader!./~/sass-loader?indentedSyntax=true!./app/styles/site.sass
42 | Module build failed: Error: ENOENT: no such file or directory, scandir
43 | ```
44 | Run `npm rebuild node-sass`.
45 |
46 | When using Microsoft Windows, install [Python 2.7](https://www.python.org/downloads/windows/) and [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools), then run
47 | ```
48 | npm install node-sass --msvs_version=2015
49 | npm rebuild node-sass
50 | ```
51 |
--------------------------------------------------------------------------------
/app/components/App.jsx:
--------------------------------------------------------------------------------
1 | export default class App {
2 | static pieces = [
3 | {name: 'webpack', link: 'http://webpack.github.io/', logo: 'Webpack.gif'},
4 | {name: 'React', link: 'http://facebook.github.io/react/', logo: 'React.svg'},
5 | {name: 'Babel', link: 'http://babeljs.io/', logo: 'Babel.png'},
6 | {name: 'Sass', link: 'http://sass-lang.com/', logo: 'Sass.svg'},
7 | ];
8 | }
9 |
--------------------------------------------------------------------------------
/app/components/Layout.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import Piece from './Piece';
4 | import App from './App';
5 |
6 | export default function Layout(props) {
7 | return (
8 |
13 | {props.children} 14 |
15 |${err.stack}`; 32 | ctx.status = err.status || 500; 33 | } 34 | }); 35 | 36 | app.use(compress({ 37 | threshold: 2048, 38 | flush: require('zlib').Z_SYNC_FLUSH 39 | })) 40 | 41 | app.use(async (ctx, next) => { 42 | let matched = true; 43 | match({routes, location: ctx.url}, (error, redirectLocation, renderProps) => { 44 | if (error) { 45 | ctx.status = 500; 46 | ctx.message = error.message; 47 | } else if (redirectLocation) { 48 | ctx.redirect(302, redirectLocation.pathname + redirectLocation.search) 49 | } else if (renderProps) { 50 | ctx.status = 200; 51 | ctx.body = generatePage(ReactDOMServer.renderToString(