npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-webpack-boilerplate-fork

v2.0.8

Published

![React](https://img.shields.io/badge/react-%5E15.5.1-brightgreen.svg) ![Redux](https://img.shields.io/badge/redux-%5E3.6.0-brightgreen.svg) ![webpack](https://img.shields.io/badge/webpack-%5E2.x.x-brightgreen.svg) ![MIT](https://img.shields.io/dub/l/v

Downloads

8

Readme

react-webpack-boilerplate

React Redux webpack MIT

A SPA boilerplate with React, built with love.

Features

  • React 15.5.1
  • Redux 3.6.0
  • react-redux 5.0.3, to bind React and Redux.
  • react-router v4 or v3, choose the one you are familiar with.
  • JSX
  • ES6, support stage-1 by default.
  • webpack 2.x
  • Express, the dev-server.
  • Hot-Reload, support both React and Redux!
  • Proxy
  • Environmental value
  • ESlint, with standard and standard-react.
  • Redux-devtools, to make the stores more clear
  • bundle-analyzer
  • jest with Enzyme, to make unit test for react components easier.

Usage

# install sao first
npm install -g sao

# download the template
sao SidKwok/react-webpack-boilerplate new-project --install

# if you would like to try React 16
sao SidKwok/react-webpack-boilerplate#next new-project --install

# install all this dependencies.
cd new-project
npm install

# development, default port: 8080
npm run dev

# production
npm run build

# build with report
npm run build --report

# lint the files (if use eslint)
npm run lint

# run all tests
npm test

Doc

It's pretty much the same config as vue-cli/webpack. If you are familiar with vue-cli, you may have a great joy with this boilerplate. If you want to have a peek of the structure, you can visit full-features branch.

Pre-Processor

You can take less, sass, or stylus as your CSS pre-processors, after installing the dependencies. For example, to use less:

npm install less less-loader --save-dev

Then, you can import your less files in your components.

postcss-config

We use postcss with autoprefixer by default. You can also use your own plugins in the project. For example, to use postcss-color-gray to "grayify" your color:

# First thing to do
npm install postcss-color-gray --save-dev

add your plugin in postcssrc.js

module.exports = {
  "plugins": {
    // to edit target browsers: use "browserlist" field in package.json
    "autoprefixer": {},
    // put your plugin here
    "postcss-color-gray": {}
  }
}

Tada! Everything is gray now.

Proxy

We uses http-proxy-middleware for proxying. For example, you want to proxy /api/get-post and /api/get-id, you can edit the option in config/index.js:

...
dev: {
  proxyTable: {
    '/api': {
      target: 'http://example.org',
      changeOrigin: true
    }
  }
}
...

Then, you can proxy /api in your dev server. See more options.

Env

This doc can illustrate the usage well.

Hot-Reload

We use react-hot-loader v3 to tweak React components, even for Redux! Have fun!

ESlint

standard and standard-react are the default style guides for this boilerplate, feel free to edit your own config in .eslintrc.js.

Router

You can use v3 or v4 as your router, and both of them support async router! As for v4, based on its concept(everything should be component, even for config), it's a little tricky on using async router. To solve this issue, we use react-loadable to split router into several chunk. It's an awesome Higher-Order-Component! It can not only split router for react, but also every single component you have. Do whatever you want to make your app neat!

Redux

You can use Redux in the project when you enable the choice. Noted that we separate two kinds of store(dev and prod) in two files. The prod one doesn't have any devtools' code, for reducing the size of bundle. If you need to apply the middlewares (redux-thunk, redux-saga and so on), you need to apply them in middlewares.js.

redux-devtools

This boilerplate has enabled the browser devtool config for Redux automatically. To make it work, you need to download the extension for your browser.

You can also choose Customized DevTools that built in your page. With this you can customized your own devtool. Click here to see more options.

Production

The production files built for server, so you are not supposed to visit index.html directly. To make it works, you may need a static server:

npm install -g serve # or others

# in `./dist`.
serve

# if you enable router
serve -s

We use babel-plugin-transform-react-remove-prop-types to remove PropType from production bundle.

bundle-analyzer

We analyze the bundle content with webpack-bundle-analyzer:

bundle-analyzer

To get this out, please run:

npm run build --report

Source Map

You can have a better experience on debugging with sourceMap in your development, but we disable it by default in production for others are not supposed to get your source code from the browser. It also can make your building process faster. Feel free to turn it on in config/index.js: productionSourceMap.

Unit test with jest

We provide jest as the default unit test library for its powerful and convenient apis. We also use Enzyme as a helper to make components more testable. All test files should place in ./test/unit/__tests__. And you need to create the files named your-js(x)-file.test.js, or it will not pass in jest. But you can set your own rules in package.json.

Known Issues

  • When combine with react-router v3, hot-reload will cause browser's error log in console. This is react-router v3's known issue, but it doesn't have other side effects. I solve this issue with a random number as a key in router, thanks to @chenz24. Noted that there is no such issue with v4.

  • ~~When combine with Redux, hot-reload will cause <Provider> does not support changing store on the fly... in the console, and break hot-reload in redux.~~

  • ~~Because of [email protected] bug, eslint was not able to work for now.~~

Reference