Git Product home page Git Product logo

imjerrybao / react-isomorphic-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chikara-chan/react-isomorphic-boilerplate

0.0 3.0 0.0 1.09 MB

🌟🌟🌟 An universal React isomorphic boilerplate for building server-side render web app.

Home Page: https://chikara-chan.github.io/react-isomorphic-boilerplate/

License: MIT License

JavaScript 85.33% CSS 7.53% HTML 7.15%

react-isomorphic-boilerplate's Introduction

React Isomorphic Boilerplate

An universal React isomorphic boilerplate for building server-side render web app.

dependencies Status devDependencies Status PRs Welcome npm

Introduction

This repository is an universal React isomorphic boilerplate for developer to quickly build a super fast and powerful web app that can be rendered both on the client and on the server using the most cutting-edge technology. Compared to others, this boilerplate has more pithily and more elegant configuration file based on environment variables, one for development, one for production. In addition, the directory structure is organized corresponding to mvc principle aim at the best practice.

Technology Stack

Getting Started

  • Require Node.js v6 or later.
  • npm install to install dependencies and devDependencies.
  • npm run dev to start up the development environment.
  • npm run build to compile and bundle the client and server files.
  • npm start to deploy the production server.

What's included

react-isomorphic-boilerplate/                // root directory
β”œβ”€β”€ build/                                   // webpack config directory
β”‚     β”œβ”€β”€ webpack.dev.config.js                 // config for webpack when run development bundle
β”‚     └── webpack.prod.config.js                // config for webpack when run production bundle
β”œβ”€β”€ client/                                  // client directory
β”‚     β”œβ”€β”€ about/                                // `about` module
β”‚     β”œβ”€β”€ common/                               // `common` module
β”‚     β”œβ”€β”€ home/                                 // `home` module
β”‚     β”œβ”€β”€ shared/                               // shared module
β”‚     β”œβ”€β”€ explore/                              // `explore` module
β”‚     β”œβ”€β”€ index.js                              // client entry file
β”‚     └── routes.js                             // client route config
β”œβ”€β”€ dist/                                    // bundle output directory
β”‚     β”œβ”€β”€ client/                               // the client side output directory
β”‚     └── server/                               // the server side output directory
β”œβ”€β”€ server/                                  // server directory
β”‚     β”œβ”€β”€ controllers/                          // controllers in server
β”‚     β”œβ”€β”€ middlewares/                          // custom middlewares in server
β”‚     β”œβ”€β”€ models/                               // models in server
β”‚     β”œβ”€β”€ routes/                               // routes in server
β”‚     β”œβ”€β”€ app.js                                // create koa instance in server
β”‚     β”œβ”€β”€ server.dev.js                         // entry file in development mode
β”‚     └── server.prod.js                        // entry file in production mode
β”œβ”€β”€ views/                                   // views directory
β”‚     β”œβ”€β”€ dev/                                  // output files generated by tpl in development mode
β”‚     β”œβ”€β”€ prod/                                 // output files generated by tpl in production mode
β”‚     └── tpl                                   // templates injected by html-webpack-plugin
β”œβ”€β”€ .editorconfig                            // uniform the text editor behavior
β”œβ”€β”€ .eslintignore                            // which paths should be omitted from linting
β”œβ”€β”€ .eslintrc.json                           // specific rules for eslint
β”œβ”€β”€ .gitattributes                           // uniform the new line perform behavior
β”œβ”€β”€ .gitignore                               // ignore the specific files when using git
β”œβ”€β”€ LICENSE                                  // license information
β”œβ”€β”€ package.json                             // npm entry file
β”œβ”€β”€ README.md                                // just what you see now
└── yarn.lock                                // lock file autogenerated by yarn

Why Isomorphic

SEO

An application that can only run in the client-side cannot serve HTML to crawlers, so it will have poor SEO by default. Web crawlers function by making a request to a web server and interpreting the result. but if the server returns a blank page, it’s not of much value. There are workarounds, but not without jumping through some hoops.

Performance

By the same token, if the server doesn’t render a full page of HTML but instead waits for client-side JavaScript to do so, users will experience a few critical seconds of blank page or loading spinner before seeing the content on the page. There are plenty of studies showing the drastic effect a slow site has on users, and thus revenue.

Maintainability

While the ideal case can lead to a nice, clean separation of concerns, inevitably some bits of application logic or view logic end up duplicated between client and server, often in different languages. Common examples are date and currency formatting, form validations, and routing logic. This makes maintenance a nightmare, especially for more complex apps.

Problem exists yet

FOUC

It happens when run in development mode. This is caused by deprecated using extract-text-webpack-plugin in development for getting a seamless hmr experience.(Why deprecated? See this Issue) If you are not an OCD, go ahead, ignore it.

Mismatch

It happens also when run in development mode. This is caused by when you update the react component code and reload the page, the markup generated mismatches that on server render. However, once you restart the server, the checksum will be valid. So it is harmless, ignore it also.

Links

http://www.jianshu.com/p/0ecd727107bb

License

MIT

react-isomorphic-boilerplate's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.