From b3aa92f9498d610220db60c0f31221a11670a454 Mon Sep 17 00:00:00 2001 From: Boopathi Rajaa Date: Fri, 11 Aug 2017 14:44:50 +0200 Subject: [PATCH] Add docs for NodeAPI and CLI --- packages/babili/README.md | 75 +++++++++++++++++++++++++++++++++----- packages/babili/src/cli.js | 7 ++++ 2 files changed, 73 insertions(+), 9 deletions(-) diff --git a/packages/babili/README.md b/packages/babili/README.md index 01855045e..28ba53d1b 100644 --- a/packages/babili/README.md +++ b/packages/babili/README.md @@ -1,8 +1,10 @@ # babili +Node API and CLI + [`babili`](/packages/babili) [![npm](https://img.shields.io/npm/v/babili.svg?maxAge=2592000)](https://www.npmjs.com/package/babili) -Use `babili` if you don't already use babel (as a preset) or want to run it standalone. Equivalent to using `babel-cli` but only for minification. +Use `babili` if you don't already use babel (as a preset) or want to run it standalone. ## Installation @@ -10,14 +12,69 @@ Use `babili` if you don't already use babel (as a preset) or want to run it stan npm install babili --save-dev ``` -### Usage +## Usage + +### Node API + +```js +const babili = require("babili"); + +const {code, map} = babili("input code", { + mangle: { + keepClassName: true + } +}); +``` + +### CLI + +```sh +babili input.js --out-file input.min.js --mangle.keepClassName +``` + +## Node API + +```js +const babili = require("babili"); + +babili(input, babiliOptions, overrides) +``` + +### babiliOptions + +Refer [babel-preset-babili options](../babel-preset-babili#options) + +## CLI Options + +``` +babili input.js [options] +``` + +### Simple preset options + +For simple options, use `--optionName` in CLI + +Refer [preset's 1-1 options](../packages/babel-preset-babili#1-1-mapping-with-plugin) for the list of options + +Example: + +``` +babili input.js --mangle false +``` + +### Nested preset options + +Usage: `--optionName.featureName` -```bash -# global -babili src -d lib -# local -./node_modules/.bin/babili src -d lib +Example: + +```sh +babili input.js --mangle.keepClassName --deadcode.keepFnArgs --outFile input.min.js ``` -Equivalent to: -`babel src -d lib --presets=babili` +Refer the corresponding plugins to know the list of options it takes + +### IO options + ++ `--out-file path/to/file.min.js`: Output filename. Used only when reading from STDIN / a single input file ++ `--out-dir path/to/dir`: Output Directory. diff --git a/packages/babili/src/cli.js b/packages/babili/src/cli.js index 50cb747f8..d12693835 100644 --- a/packages/babili/src/cli.js +++ b/packages/babili/src/cli.js @@ -103,6 +103,13 @@ function printHelpInfo({ exitCode = 0 } = {}) { --typeConstructors Minify constructors to equivalent version --undefinedToVoid Transforms undefined into void 0 --version, -V Prints the current version number + + Nested Options: + To use nested options (plugin specfic options) simply use the pattern + --pluginName.featureName. + + For example, + babili index.js --mangle.keepClassName --deadcode.keepFnArgs --outFile index.min.js `; log(msg, exitCode); }