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

generator-create-redux-app

v1.2.4

Published

Add redux, emotion-js and other useful libraries like react-router in top of create-react-app

Downloads

22

Readme

Generator create-redux-app

NPM

This generator add redux, emotion-js and other useful libraries and tools like react-router, in top of the most common React starter Create React App. Below you will find some information on how to perform common tasks.

Installation

First, install Yeoman and generator-create-redux-app using npm ( You’ll need to have Node >= 6.10.3 on your machine node.js).

npm install -g yo
npm install -g generator-create-redux-app

Then generate your new project:

mkdir project-name
cd project-name
yo create-redux-app

Once the installation is done, you can run some commands inside the project folder:

npm start or yarn start

Runs the app in development mode. Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits. You will see the build errors and lint warnings in the console.

npm test or yarn test

Runs the test watcher in an interactive mode. By default, runs tests related to files changes since the last commit.

Read more about testing.

npm run build or yarn build

Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes. Your app is ready to be deployed!

User Guide

Folder Structure

create-redux-app override create-redux-app folder structure. Once the generator runs your project folders should look like this:

my-app/
  docs/
  public/
    index.html
    favicon.ico
  src/
    actions/
    assets/
    components/
    constants/
    containers/
    reducers/
    routes/
    store/
    tests/
    styles/
    utils/
    index.js

For the project to build, these files must exist with exact filenames:

  • public/index.html is the page template;
  • src/index.js is the JavaScript entry point.

You can delete or rename the other files.

You may create subdirectories inside src. For faster rebuilds, only files inside src are processed by Webpack. You need to put any JS and CSS files inside src, or Webpack won’t see them.

Only files inside public can be used from public/index.html. Read instructions below for using assets from JavaScript and HTML.

You can, however, create more top-level directories. They will not be included in the production build so you can use them for things like documentation.

Redux Dev Tools

Create Redux App use Redux DevTools Extension. It provides access to the most popular monitors, is easy to configure and to filter actions.

Installation

1. For Chrome

2. For Firefox

3. For Electron

4. For other browsers and non-browser environment

Git Hooks

We use Husky to create Git Hooks. There is a pre commit hook than run prettier to ensure good code format. You can also create a prepush hook.

// Edit package.json

"husky": {
  "hooks": {
    "pre-commit": "pretty-quick --staged"
  }
},

Uninstall

npm uninstall husky --save-dev

And delete the husky key inpackage.json

Prettier

You can add/remove rules if you want, just edit the .prettierrc file. Prettier runs in a precommit hooks to ensure good code formating with pretty-quick.

// Edit package.json

"scripts": {
  "format": "prettier --write '**/*.{js,jsx,json,md}'",
  "format:changed": "pretty-quick",
  "format:staged": "pretty-quick --staged",
  "eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check"
},
"husky": {
  "hooks": {
    "pre-commit": "pretty-quick --staged"
  }
},

Uninstall

npm uninstall eslint-config-prettier pretty-quick prettier --save-dev

Delete

"scripts": {
  "format": "prettier --write '**/*.{js,jsx,json,md}'",
  "format:changed": "pretty-quick",
  "format:staged": "pretty-quick --staged",
  "eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
},
"husky": {
  "hooks": {
    "pre-commit": "pretty-quick --staged"
  }
},

ESLint

You can add/remove rules or even extend plugins if you want. We extend airbnb ESLint rules.

// Edit eslintrc.json

{
  "extends": ["airbnb", "prettier", "prettier/react"],
  "plugins": ["prettier"],
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 2016,
    "sourceType": "module"
  },
  "env": {
    "es6": true,
    "jest": true,
    "browser": true,
    "node": true
  },
  "globals": {
    "DEBUG": false
  },
  "rules": {
    "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
    "import/no-extraneous-dependencies": 0,
    "import/no-unresolved": 0,
    "import/extensions": 0,
    "import/prefer-default-export": 0,
    "import/first": 0
  }
}

Routing

The best option for routing is React Router specifically its new version for the web react-router-dom. src/routes/index.js is the starter point of the app, where all the routes are specified and render the containers and components. Specify here all your routes, redirects, transitions, etc.

Emotion Js

emotion-js allow you to write actual CSS code in your JavaScript to style your components, removing the mapping between components and styles.

See the official documentation for more information!

Adding Sass Preprocessor

Can I use Sass with this boilerplate? yes, although we advise against it and do not support this. We selected styled-components over Sass because its approach is more powerful: instead of trying to give a styling language programmatic abilities, it pulls logic and configuration out into JS where we believe those features belong.

If you really still want (or need) to use Sass then...

Redux Store

The Redux store is created this way so you can use it anywhere, even outside redux, in any js file.

const { default: store } = process.env.NODE_ENV === 'production'
  ? require('./storeProd')
  : require('./storeDev')

module.exports = store()

Usage

import store from './store'

store.getState() // Get the state
store.dispatch() // Dispatch actions

Create React App config

You can find the most recent version of the create-react-app guide here.

License

MIT License