a build tool for developing front-end applications at REPAY
Last updated 5 months ago by jamesnimlos .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @repay/scripts 
SYNC missed versions from official npm registry.


The CLI tools used for building and bundling javascript packages at REPAY. Uses the @repay/babel-preset, overrides not currently available except through customizing the config.


Add @repay/scripts to your project with yarn add --dev @repay/scripts

Web application

To run a web application with reloading, call the dev command with your entry file:

// src/index.js

In the command line:

repay-scripts dev src/index.js

Open your browser to https://localhost:3434

When development is finished, call the build command with your entry file to generate a distributable:

repay-scripts build src/index.js

CLI Commands

Output from repay-scripts --help

repay-scripts <command>

  repay-scripts build <entry>  build a javascript library or front-end
  repay-scripts dev <entry>    build a javascript library or front-end
                               application for local development

  --lib           is this a javascript library        [boolean] [default: false]
  --babel-env     set the babel environment
               [string] [choices: "development", "test", "production"] [default:
  --config, -c    path to override configuration        [string] [default: null]
  --debug         adds extra logging for debugging purposes
                                                      [boolean] [default: false]
  --tree-shaking  enables treeshaking for libraries   [boolean] [default: false]
  -h, --help      Show help                                            [boolean]
  -v, --version   Show version number                                  [boolean]

Using the tree-shaking option

Only applicable to libraries.

Adding the --tree-shaking option will create a commonjs bundle normally, but then use Babel directly instead of bundling the ES modules. This allows for more aggressive tree shaking or code splitting when the library is used for the front-end. Additionally, the library should implement the sideEffects property in it's package.json to allow bundlers to confidently remove unused files.


repay-scripts build --tree-shaking --lib src/index.ts

Using config option

The config options is passed a file which should export a single function as the module.exports which will be called with the pre-made configuration and the options provided to repay-scripts as the arguments, and must return a configuration.

web app example

# shell command
repay-scripts dev --config webpack.config.js src/index.js
// webpack.config.js
module.exports = (config, options) => {
  // access options to determine what changes to make
  if (options.command === "dev") {
    config.performance = { hints: false };
  // returns config whether modified or not
  return config;

library example

# shell command
repay-scripts dev --config rollup.config.js --lib src/index.ts
// rollup.config.js
module.exports = (config, options) => {
  // remove ESM build
  config.outputs.splice(0, 1);
  // always return config
  return config;

Optimizing Bundles

By default, @repay/scripts splits out the webpack runtime as a bundle to prevent unnecessary content hash updates. You can read more about the option here.

When generating bundles for client facing applications, it's ideal to take libraries used and host them in a separate "vendor" or "common" bundle. This bundle can be cached between releases when the libraries are not upgraded. Here is an example implementation when using @repay/scripts and the config option.

// repay-scripts.config.js
module.exports = (baseConfig, options) => {
  if (options.env === "production") {
    // adds library bundles for cactus and react libraries
    baseConfig.optimization.splitChunks.cacheGroups = {
      cactus: {
        test: /[\\/]node_modules[\\/]cactus-/,
        name: "cactus",
        chunks: "all"
      react: {
        // selects both react and react-dom into a separate bundle
        test: /[\\/]node_modules[\\/]react(-dom)?[\\/]/,
        name: "react",
        chunks: "all"
  return baseConfig;

You can learn more about the splitChunks object and options in the webpack docs.

Current Tags

  • 0.3.1                                ...           latest (5 months ago)
  • 0.2.0-next                                ...           next (8 months ago)

10 Versions

  • 0.3.1                                ...           5 months ago
  • 0.3.0                                ...           5 months ago
  • 0.2.2                                ...           8 months ago
  • 0.2.1                                ...           8 months ago
  • 0.2.0                                ...           8 months ago
  • 0.2.0-next                                ...           8 months ago
  • 0.1.1                                ...           8 months ago
  • 0.1.0                                ...           8 months ago
  • 0.0.2                                ...           9 months ago
  • 0.0.1                                ...           9 months ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 11
Dev Dependencies (7)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |