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-react-webpack-scaffold

v2.0.0

Published

Yeoman generator for generating the boilerplate of React Webpack application with Karma Mocha testing frameworks.

Downloads

23

Readme

#React Webpack Scaffold

NPM Version Node Version Build Status Coverage Status

NPM

Yeoman

A Yeoman generator that scaffolds React project with Webpack, Karma and more useful tools for you to write React application and unit tests.

##How to install

Step 1. Install Yeoman

$ npm install -g yo
$ npm install -g generator-react-webpack-scaffold

Step 2. Run yo react-webpack-scaffold in an empty project folder

$ cd your-empty-project-folder
$ yo react-webpack-scaffold

Demo

That's it! Now you have a fully functional React project.

##Features

The scaffolded project has the following features:

###1. React

The following features are supported:

Functional Component

const App = () => (
    <div className='main-app'>
        <h1>Hello, World!</h1>
    </div>
);

Class Component

class App extends Component {
    render() {
        return (
            <div className='main-app'>
                <h1>Hello, World!</h1>
            </div>
        );
    }
}

Class Properties

class Menu extends Component {
    static propTypes = {
        className: PropTypes.string,
    };
    ...
}

Export Default

export default App;

Import .scss in Component

import './styles.scss';
const App = () => <div />;

###2. Localization

We use Yahoo's React Intl (v2.0) library to support localization.

1. To support a new locale, e.g. ja-JP, copy i18n/en-US.properties to i18n/ja-JP.properties, translate the locale messages.

2. Specify a LOCALE env var in npm start to debug for a specific locale:

$ LOCALE=en-US npm start

You can also build the bundle.js for a specific locale:

$ LOCALE=en-US npm run build

This will output the English bundle.js in dist/en-US folder. Note, if you don't specify LOCALE, default is en-US.

3. To build bundle.js for all languages:

$ npm run release

This will output each supported language bundle.js along with the style sheets in dist/{locale} folder.

###3. Webpack dev server When you run your project by npm start, webpack dev server watches the source files for changes and when changes are made the bundle will be recompiled.

###4. Sass loader You can define styles for individual React components using import. The good thing about importing styles is that you can define some base styles and import them for component-level styles.

###5. Unit test Assert & Expect

import { assert, expect } from 'chai';
...

Enzyme

import { shallow } from 'enzyme';
describe('Testing', () => {
    it('should render the App', () => {
        const wrapper = shallow(<App />);
        ...
    });
});

Sinon

const sandbox = sinon.sandbox.create();
describe('Testing', () => {
    afterEach(() => sandbox.verifyAndRestore());
    it('should call the callback', () => {
        const callback = sandbox.stub();
        ...
    });
});

###6. Coverage Report Code coverage report is geneated by istanbul. npm run coveralls will submit the coverage report to coveralls.io.

You can setup passing thresholds for statements, branches, functions and lines.

Example:

==================== Coverage / Threshold summary =============================
Statements   : 100% ( 46/46 ) Threshold : 90%, 4 ignored
Branches     : 100% ( 31/31 ) Threshold : 90%, 13 ignored
Functions    : 100% ( 10/10 ) Threshold : 90%
Lines        : 100% (  6/6  ) Threshold : 90%
================================================================================

The HTML and lcov reports can be found in the coverage folder.

##What can you do in the scaffolded project

####1. Run the project Launch webpack dev server

$ npm start

then navigate to http://localhost:5000 in your browser.

####2. Lint js and scss source codes ESLint with React linting options have been enabled.

$ npm run lint

####3. Unit test Start Karma test runner.

$ npm run test

Coverage report will be generated.

####4. Build the bundle Build files for production

$ npm run build

####5. Clean workspace Remove dist and coverage folders

$ npm run clean

###For localization feature

####1. Hot-load for a lanuage

$ LOCALE=en-US npm start

####2. Build bundle.js for a language

$ LOCALE=en-US npm run build

####3. Build all language bundles

$ npm run release