scriptoni
Configuration and scripts for buildo React apps
Last updated 2 months ago by ecaml .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install scriptoni 
SYNC missed versions from official npm registry.

scriptoni

A set of shared scripts for your front-end apps.

Quick start

  1. yarn add --dev scriptoni
  2. add any script you like to your package.json (e.g. "metarpheus": "scriptoni metarpheus")
  3. profit!

Scripts

metarpheus

Metarpheus generates io-ts-annotated TS models based on your Scala API. To use, add this script to your package.json:

"metarpheus": "scriptoni metarpheus"

By default, Metarpheus will look for your API at ../api/src/main/scala, but you can override this (and many other option) by creating a metarpheus-config.js file in your project directory. If this file is found, it will be merged with scriptoni's default configuration. Only the options you specify will be overridden.

metarpheus-diff

metarpheus-diff performs a diff between the existing generated models/api and the new ones. It can be used on a CI server to catch uncommitted updates to generated models and api.

Its configuration is identical to the one of the metarpheus script.

webpack

Bundling your application with webpack is awesome. What's less awesome is having to configure it on every single project. scriptoni provides a default battle-tested webpack configuration for both development and production builds.

Add these scripts to your package.json:

"start": "UV_THREADPOOL_SIZE=20 scriptoni web-dev -c ./config",
"build": "UV_THREADPOOL_SIZE=20 scriptoni web-build -c ./config"

where:

  • the UV_THREADPOOL_SIZE trick is a workaround for a known issue with the sass-loader (https://github.com/webpack-contrib/sass-loader/issues/100). You'll need this only if your project has more than a few .sass files
  • the -c ./config points to a directory containing the configurations for your project (read more below).

./config directory

The config directory should include:

  • a Config.js file. It should export a io-ts type validating the configuration. Currently only port is strictly required by scriptoni webpack to work
  • any of production.json, development.json, local.json (all are optional): production and development should be tracked in version control, they are the default/base for NODE_ENV=production and =development, respectively. local.json is inteded to be used for custom, per-developer config tweaks, and should not be committed.

The final configuration used to run webpack is obtained by merging development.json (production.json if NODE_ENV=production), local.json (which takes precedence) and (with maximum priority) environment variables corresponding to single config keys.

Environment variables follow this rule: to affect e.g. the title: t.String config key, you can provide the CONFIG_TITLE=title variable before running scriptoni web-dev (or web-build).

The virtual 'config' module obtained is available as import config from 'config' anywhere in your code base.

Not every config keys is actually part of the final bundle, In other words, not every config key is visible to TS code when importing from 'config'. The bundled configs should be specified as part of a sub-key bundle:

// config/Config.js
t.interface({
  port: t.Integer,
  bundle: t.interface({
    apiEndpoint: t.String
  }, { strict: true })
}, { strict: true })

// config/local.json
{
  "port": 8080 // non-bundled, this is available to webpack but not to TS code,
  "bundle": {
    "apiEndpoint": "example.com" // bundled, you can use `config.apiEndpoint` from TS code
  }
}

See https://github.com/buildo/webseed/tree/master/config for an example/minimal configuration.

custom Webpack config

The default webpack config shipped with scriptoni should be fine in most cases. However, you may need to change something. If this is the case, you can override the default config by passing an additional --webpackConfig argument, followed by the file path containing your override function.

Let's say, for example, you want to change the output library. You can provide a webpack.config.js file in the root directory of your project, with the following content:

module.exports = (defaultConfig, { config, paths, NODE_ENV, bundleAnalyzer, target }) => ({
  ...defaultConfig,
  output: {
    ...config.output,
    library: 'myclient'
  }
});

As you can see, your function will receive the default webpack config as first argument, followed by an object containing useful options:

  • config: the app config (see the previous chapter)
  • paths: the map of the paths used by your project
  • NODE_ENV: 'development' or 'production'
  • bundleAnalyzer: true or false

As a last step, you can change the start and build scripts in your package.json file by adding --webpackConfig ./webpack.config.js at the end of both commands:

"start": "UV_THREADPOOL_SIZE=20 scriptoni web-dev -c ./config --webpackConfig ./webpack-config.js",
"build": "UV_THREADPOOL_SIZE=20 scriptoni web-build -c ./config --webpackConfig ./webpack-config.js"

Current Tags

  • 7.0.1                                ...           7_0_X (2 months ago)
  • 8.0.1                                ...           latest (2 months ago)
  • 0.10.2-0                                ...           next (2 years ago)

96 Versions

  • 7.0.1                                ...           2 months ago
  • 8.0.1                                ...           2 months ago
  • 8.0.0                                ...           3 months ago
  • 7.0.0                                ...           9 months ago
  • 6.1.0                                ...           10 months ago
  • 6.0.0                                ...           10 months ago
  • 5.0.0                                ...           10 months ago
  • 4.0.1                                ...           10 months ago
  • 4.0.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.17.0                                ...           a year ago
  • 0.16.0                                ...           a year ago
  • 0.15.2                                ...           a year ago
  • 0.15.1                                ...           a year ago
  • 0.15.0                                ...           a year ago
  • 0.14.2                                ...           a year ago
  • 0.14.1                                ...           a year ago
  • 0.14.0                                ...           a year ago
  • 0.13.0                                ...           a year ago
  • 0.12.5                                ...           a year ago
  • 0.12.4                                ...           2 years ago
  • 0.12.3                                ...           2 years ago
  • 0.12.2                                ...           2 years ago
  • 0.12.1                                ...           2 years ago
  • 0.12.0                                ...           2 years ago
  • 0.11.3                                ...           2 years ago
  • 0.11.2                                ...           2 years ago
  • 0.11.1                                ...           2 years ago
  • 0.11.0                                ...           2 years ago
  • 0.10.2                                ...           2 years ago
  • 0.10.2-0                                ...           2 years ago
  • 0.11.0-0                                ...           2 years ago
  • 0.10.1                                ...           2 years ago
  • 0.10.0                                ...           2 years ago
  • 0.9.1                                ...           2 years ago
  • 0.9.0                                ...           2 years ago
  • 0.8.0                                ...           2 years ago
  • 0.7.10                                ...           2 years ago
  • 0.7.9                                ...           2 years ago
  • 0.7.8                                ...           2 years ago
  • 0.7.7                                ...           2 years ago
  • 0.7.6                                ...           2 years ago
  • 0.7.5                                ...           2 years ago
  • 0.7.4                                ...           2 years ago
  • 0.7.3                                ...           2 years ago
  • 0.7.2                                ...           2 years ago
  • 0.7.1                                ...           2 years ago
  • 0.7.0                                ...           2 years ago
  • 0.6.16                                ...           2 years ago
  • 0.6.15                                ...           2 years ago
  • 0.6.14                                ...           2 years ago
  • 0.6.13                                ...           2 years ago
  • 0.6.12                                ...           2 years ago
  • 0.6.11                                ...           2 years ago
  • 0.6.10                                ...           2 years ago
  • 0.6.9                                ...           2 years ago
  • 0.6.8                                ...           2 years ago
  • 0.6.7                                ...           2 years ago
  • 0.6.6                                ...           2 years ago
  • 0.6.5                                ...           2 years ago
  • 0.6.4                                ...           2 years ago
  • 0.6.3                                ...           2 years ago
  • 0.6.2                                ...           2 years ago
  • 0.6.1                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.5                                ...           2 years ago
  • 0.5.4                                ...           2 years ago
  • 0.5.3                                ...           3 years ago
  • 0.5.2                                ...           3 years ago
  • 0.5.1                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.4.4                                ...           3 years ago
  • 0.4.3                                ...           3 years ago
  • 0.4.2                                ...           3 years ago
  • 0.4.1                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.3                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.9                                ...           3 years ago
  • 0.1.8                                ...           3 years ago
  • 0.1.7                                ...           3 years ago
  • 0.1.6                                ...           3 years ago
  • 0.1.5                                ...           3 years ago
  • 0.1.4                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 33
Dependencies (40)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |