Skip to content

Commit

Permalink
Add docs for NodeAPI and CLI (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
boopathi authored Aug 11, 2017
1 parent 2874b46 commit 31d1ce5
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 9 deletions.
75 changes: 66 additions & 9 deletions packages/babili/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,80 @@
# 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

```sh
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.
7 changes: 7 additions & 0 deletions packages/babili/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 31d1ce5

Please # to comment.