Coder Social home page Coder Social logo

bpmckee / redux-webpack-es6-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nicksp/redux-webpack-es6-boilerplate

0.0 1.0 0.0 86 KB

A starter project for modern React apps with Redux

License: MIT License

JavaScript 91.35% HTML 2.28% CSS 6.37%

redux-webpack-es6-boilerplate's Introduction

React + Redux w/ ES6 Starter Project

A boilerplate using React, Redux, webpack + hot module reloading, and ES6 + JSX via Babel.

The provided boilerplate enables client-side ES6 via the following technologies:

  • webpack and webpack-dev-server as a client-side module builder and module loader.
  • npm as a package manager and task runner (say NO to gulp/grunt).
  • Babel 6 as a transpiler from ES6 to ES5.
  • React and JSX as a virtual Dom JavaScript library for rendering user interfaces (views).
  • Redux as an incredibly simple way of modelling your data app state, with great community support.
  • Redux DevTools as a live-editing environment for your Redux apps.
  • ESLint as a reporter for syntax and style issues. eslint-plugin-react for additional React specific linting rules.
  • Sass as a compiler of CSS styles with variables, mixins, and more.
  • Mocha as a test framework.
  • Chai as a BDD assertion library that works along with Mocha.

Getting Started

Installation

$ git clone https://github.com/nicksp/redux-webpack-es6-boilerplate.git app-name
$ cd app-name
$ npm install

White Label It

  • Update name, desription, author, repository in package.json
  • Update app title in src/index.html

Development

There are two ways in which you can build and run the web app:

  • Build once for (ready for Production):

    • $ npm run build
    • Open build/index.html through the local webserver
  • Hot reloading via webpack dev server:

    • $ npm start
    • Point your browser to http://localhost:3000/, page hot reloads automatically when there are changes

Testing

To execute all unit tests, use:

npm run test

To run unit tests continuously during development (watch tests), use:

npm run test:watch

FAQ

What's this for?

This starter kit implements best practices like testing (unit testing), minification, bundling, and so on. It saves you from the long, painful process of wiring it all together into an automated dev environment and build process.

What's happening under the hood when I run npm start?

Webpack serves your app in memory when you run npm start. No physical files are written. However, the web root is /src, so you can reference files under /src in index.html. When the app is built using npm run build, physical files are written to /build folder and the app is served from /build.

How is Sass being processed?

We're handling it differently in DEV vs PROD.

When you run npm start:

  1. The sass-loader compiles Sass into CSS
  2. Webpack bundles the compiled CSS into app.js. Sounds weird, but it works!
  3. app.js contains code that loads styles into the <head> section of index.html via JavaScript. This is why there is no stylesheet reference in index.html. In fact, if you disable JavaScript in your browser, you'll see the styles don't load either.

The approach above supports hot reloading, which is great for development. However, it also create a flash of unstyled content on load because you have to wait for the JavaScript to parse and load styles before they're applied. So for the production build, we use a different approach:

When you run npm run build:

  1. The sass-loader compiles Sass into CSS
  2. The extract-text-webpack-plugin extracts the compiled Sass into app.css
  3. buildHtml.js adds a reference to the stylesheet to the head of index.html.

How do I deploy this?

npm run build. This will prepare and build the project for production use. It does the following:

  • Minifies all JS and CSS
  • Inline base64 URLs for images and fonts if their size is less than specified limit
  • Sets NODE_ENV to production so that React is built in production mode
  • Places the resulting built project files into /build directory. (This is the folder you'll expose to the world).

TODO

  • Watch index.html for changes
  • Add an ability to test React components using Karma and Jasmine
  • Make a lightweight version of boilerplate (exclude Redux support?)

License

MIT

Brought to you by Nick S. Plekhanov

redux-webpack-es6-boilerplate's People

Contributors

andyklimczak avatar nicksp avatar

Watchers

 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.