Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add docs for NodeAPI and CLI #653

Merged
merged 1 commit into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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