Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @rexlabs/plz-cli with all npm packages installed. Try it out:

require("react/package.json"); // react is a peer dependency. require("react-dom/package.json"); // react-dom is a peer dependency. var plzCli = require("@rexlabs/plz-cli")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@rexlabs/plz-cli v3.2.14

Toolkit for creating, developing building & testing projects - Vivid Module

@rexlabs/plz-cli :pray:

CLI toolkit for frontend web dev at rexlabs, enabling you to:

The latest version of plz comes with webpack 4, babel 7, jest 24 and storybook 5, as well as everything needed to support React 16.9 😊

Why? — Rationale

"Oh geez, another front dev tool" ... wrong!
This is a kit of tools - it says so in the first sentence. It is 💯 gud.

Frontend development is filled to the brim with open source tools like webpack, babel, jest and storybook. As great as they are, they're difficult to configure, don't play nice together, and each new tool introduces learning curves. Boo.

Rather than we all struggling through the pains of configuration setup and maintenance, in each app and package we build @ rexlabs, we invest all that tooling focus into plz. It can sit in front of these tools, with a bunch of sane default configurations and hacks, to then be consistently employed in our projects. Devs are given the opportunity to forget about tooling woes, freeing their minds for better tasks. What a pleasant experience!

Why not just use create-react-app?

CRA, or more specifically react-scripts, is an amazing toolkit and one of the starters of this trend we're now seeing. However, it is (for very good reasons) very opinionated when it comes to the ability to customise it. We needed something a little bit more flexible, since every app after all is different and will have different requirements to certain extends.

Also, we wanted a toolkit that would allow us to build all kinds of projects, not just apps. Since we heavily invest in building centralised components and solutions in form of npm libraries, we were looking for a toolkit that could sit on top of any form of project. This is exactly what plz does 😊

Shoutout 🙌

Even though he's not working at rexlabs anymore, Lochlan Bunn still deserves a massive shout out here. Not only did he create plz in the first place, he also drove its adaption, educating everyone about the concepts, motivations and benefits. Without his work this library and the work that we do thanks to it would not be the same 🎉

Getting started

# Install plz globally to use it for bootstrapping new projects
npm i -g @rexlabs/plz-cli
plz <command> [options]

# ...or use npx
npx @rexlabs/plz-cli <command> [options]


$ plz --help

  plz build                     Bundles a project for distribution.
  plz clean                     Removes previously built files.
  plz config [key] [value]      Sets (or reads) config of the plz instance.
                                Can be used to change defaults.
  plz create <name> [root-dir]  Generates a new project called <name>
  plz serve                     Starts an dev server for the project.
  plz stories                   Starts a storybook for UI components.
  plz test [options]            Starts a jest test runner in current
  plz use <package-name>        Sets the given package as template source.
                                See --help for more details.

  -h, --help  Show help                                                [boolean]
  --no-emoji  Strip all emojis from the cli output in the terminal.    [boolean]
  --report    Add memory reporting at the end of each command execution.
  --version   Show version number                                      [boolean]

Run `plz --help` or `plz <command> --help` to get more info.

Run `DEBUG=plz plz <command> [options]` to get more detailed output for

CLI Commands and options


Creates a new project.

$ plz create <name> [root-dir]

Generates a new project called <name>

  name      Name of the project, will be used by default for the name of the
            generated directory.                             [string] [required]
  root-dir  Optional root directory for new project                     [string]

  -h, --help          Show help                                        [boolean]
  --no-emoji          Strip all emojis from the cli output in the terminal.
  --report            Add memory reporting at the end of each command execution.
  --version           Show version number                              [boolean]
  --project-type, -t  Project type, one of: react-app, react-component,
                      module.The tooling configs (webpack, babel, etc.) will be
                      determined from the project type.   [default: "react-app"]
  --template, --tpl   Optional custom URL of template repo to be used for the
                      project. Templates use handlebars to create directories
                      and files dynamically.


Name of the project, will be used by default for the name of the generated directory. It will also be passed down to the template to be used for the package name, core class names, etc.


The type of project you want to create. This determines the default template, as well as the default configs and setup for the other commands.


By default plz will pick the template, according to the project type, from the src/templates/[type] folder. Optionally you can pass in your own template, either via path (relative to the current working directory), or via git repo. You can also define a sub directory of a repo, by just extending the repo URL with the dir path, e.g.:

# Relative path
plz create new-project --template ./my/relative/sub-folder

# Github repo
plz create new-project --template

# Github repo with subfolder specified
# This will clone `` and then copy `some/sub-folder`
# based on the repos root directory
plz create new-project --template

The above will clone and then use the sub directory some/sub-folder (relative to the repo's root folder) as the template directory.

You can also override the default template via plz config, so you don't have to always manually specify them when using plz.

# set template.[type], can be any format mentioned above
plz config templates.react-app ./my/relative/sub-folder

If you want to use an npm package for your templates, you can use the plz use shortcut.

npm i -g my-template-package
plz use my-template-package

Templates are parsed using copy-template-dir, which allows injecting variables via mustache syntax. See below for more details and available variables. For more details on how templates work see the advanced docs.


Exclusive to project type react-app!

Starts webpack dev server for a dev enviroment with good developer experience.

$ plz serve

  -h, --help      Show help                                            [boolean]
  --version       Show version number                                  [boolean]
  --port          Port for the dev server.                       [default: 3000]
  --host          Host for the dev server.                [default: "localhost"]
  --open-browser  Open the server automatically in the default browser once it
                  is started.                                    [default: true]

port / host

Port and host to be used for the dev server. By default, plz will start the server on http://localhost:3000. If the port is already used, plz will prompt you with the option to use the next available port instead.


By default plz will automatically open the dev environment in your default browser once the server is successfully started. If you don't want that, you can disable it via plz serve --open-browser=false.


Bundles a project for distribution.

$ plz build

Bundles a project for distribution.

  -h, --help  Show help                                                [boolean]
  --no-emoji  Strip all emojis from the cli output in the terminal.    [boolean]
  --report    Add memory reporting at the end of each command execution.
  --version   Show version number                                      [boolean]
  --stats     Use this option to generate webpack stats during the build and
              automatically start webpack-bundle-analyzer after successful
  --serve     Starts express server to serve the production bundle after
              successful build.

The output depends on the project type. Modules and React components will be bundled optimised for releasing them as npm libraries, while React apps will be bundled into a public directory optimised for deployment. Plz will default the NODE_ENV to production, unless manually specified otherwise.


For react apps you can run plz build --stats. This will run the normal build, and then automatically run webpack-bundle-analyser, giving you a nice visual representation of your bundles and which dependencies they consist of. This can be really useful when trying to improve your bundle size 😊


Also for react apps, you can run plz build --serve. Again, this will build your app normally, but will then start up a local node server to serve that build. This can be helpful if you want to test your application in production mode.


Opens development environment, starting a Storybook dev server. Plz will pick up stories from src/.stories.js by default, you can override this via the storybook.storiesPattern config.

$ plz stories

  -h, --help    Show help                                              [boolean]
  --version     Show version number                                    [boolean]
  --port        Port for the storybook server.                   [default: 3001]
  --root-dir    Directory to search in, for multiple package stories.
                                                [string] [default: "components"]
  --output-dir  Directory to build & output a static storybook app.     [string]


Same as with serve, the port for the dev server. Again, plz will prompt you if the port is already in use. Defaults to http://localhost:3001.


This option is for monorepo support. If you're maintaining a monorepo with multiple repos that all contain stories (ideally bootstrapped via plz to ensure proper folder structure), you can run plz serve from the root specifying the root dir for all the repos you want plz to look in for stories.


If you specify this, instead of booting up the dev server, plz will run build-stories and put the output into the specified output directory. This can be useful e.g. for CI, if you want to create a static build of storybook for you master or PR branches.


Runs jest tests on the project.

$ plz test

  -h, --help  Show help                                                [boolean]
  --version   Show version number                                      [boolean]
  --watch     Rerun tests when files change.          [boolean] [default: false]

Any options will be passed through to jest itself, so you can use everything you already know, e.g. --watch, --coverage, etc.


Set instance config key value pair, or read current config. This can be useful for globally installed plz instances, e.g. to override the templates used for the create command.

$ plz config [key] [value]

Sets (or reads) config of the plz instance. Can be used to change defaults.

  key    Config key                                                     [string]
  value  Config value for given key, if a relative path is given it will be
         resolved based on the current working directory.               [string]

  -h, --help  Show help                                                [boolean]
  --no-emoji  Strip all emojis from the cli output in the terminal.    [boolean]
  --report    Add memory reporting at the end of each command execution.
  --version   Show version number                                      [boolean]
  --get       Read config value(s).

Example for overriding the default template for react apps:

plz config templates.react-app ./my/custom/path


Abstraction for config, using the given npm package for template paths in the cli default config.

$ plz use <package-name>

Sets the given package as template source. See --help for more details.

  package-name  Name of globally installed npm package. It needs to be already
                installed, plz will use "npm root -g" to find the given package.
                                                             [string] [required]

  -h, --help  Show help                                                [boolean]
  --no-emoji  Strip all emojis from the cli output in the terminal.    [boolean]
  --report    Add memory reporting at the end of each command execution.
  --version   Show version number                                      [boolean]


If you need to troubleshoot issues, you might find the more verbose debug output helpful. To show these, simply run:

DEBUG=plz plz <command> [options]

You can find more info here:


Config for the plz 🙏 cli is resolved from established configuration files like other cli tools.

  • the plz property in package.json file
  • the .plzrc file (optionally with .json, .yaml, .js extensions)
  • the .plz.config.js file

The Javascript versions are especially helpful when overriding the tool configs, as you will want to define a function that receives the proposed config and returns your adjusted version.

Available options

  // Project type, determines how project is bootstraped, built, served, etc.
  // One of "react-app", "react-component" and "module"
  "projectType": "react-component",

  // Build dir, by default "public" for React apps
  // For modules and React components its the project root, since they
  // will generate multiple bundle dirs (module, lib)
  "buildDir": "public",

  // If enabled it adds css modules support to the project
  "cssModules": false,

  // When enabled, packages found in node_modules/ that have a package.json
  // plz:main field will be compiled & watched with Babel
  // This can be especially helpful within monorepos
  "runtimeCompilation": false,

  // A map of proxy configs
  // See "further documentation" for more details
  "proxy": {},

  // All options for Storybook's runtime
  "storybook": {},

  // The version of corejs to apply polyfills with using `@babel/preset-env`
  "corejs": 3,

  // Middleware for babel config
  "babel": (config) => config,

  // Same for webpack
  "webpack": (config) => config

For more details about the tool configs see the futher documentation.


Structure of this repo

├── # Automatically generated by lerna!
├── __tests__ # Test files for plz, run via `yarn test(:watch)`
├── package.json
├── src
│   ├── bin.js # Node binary entry point
│   ├── commands # Commands dir, automatically detected through yargs
│   │   ├── build.js
│   │   ├── clean.js
│   │   ├── create.js
│   │   ├── serve.js
│   │   ├── stories.js
│   │   └── test.js
│   ├── configs # Tooling configs + collection for project types in `project`
│   │   ├── babel
│   │   ├── jest
│   │   ├── project
│   │   ├── storybook
│   │   └── webpack
│   ├── index.js # Entry point for imports
│   ├── templates # Default templates for the different project types
│   │   ├── module
│   │   ├── react-app
│   │   └── react-component
│   └── utils # General util methods
└── support # Any node helper scripts

All commands are automatically detected by yargs through the commandDir method, which is set to /commands. Files in there need to export all the command relevant information themselves.

Running tests

# Watch for changes, rerunning tests
yarn test:watch

# Run watch once
yarn test

# Get test coverage
yarn test --coverage

Further documentation




  • [ ] Typescript support
  • [ ] Better error handling and more helpful / meaningful messages
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free