https://github.com/differui/rollup-plugin-if
Roll JavaScript with if instructions.
https://github.com/differui/rollup-plugin-if
rollup rollup-plugin
Last synced: 11 months ago
JSON representation
Roll JavaScript with if instructions.
- Host: GitHub
- URL: https://github.com/differui/rollup-plugin-if
- Owner: differui
- License: mit
- Created: 2016-09-14T05:06:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-12T04:55:21.000Z (about 9 years ago)
- Last Synced: 2025-02-24T05:17:42.693Z (11 months ago)
- Topics: rollup, rollup-plugin
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
rollup-plugin-if
=====
## Install
```bash
$ npm install rollup-plugin-if -D
```
## Syntax
```
#[keyword] [expression]
// javascript code goes here
#end[keyword]
```
## Usage
```js
import { rollup } from 'rollup';
import instruction from 'rollup-plugin-if';
rollup({
entry: 'main.js',
plugins: [
instruction({
FLAG1: true,
FLAG2: true
})
]
}).then(...);
```
## Statements
### `if`
```js
#if FLAG
window.a = 1;
#endif
window.b = 2;
```
```json
{
"FLAG": true
}
```
will yeild:
```js
window.a = 1;
window.b = 2;
```
### `if`-`else`-`endif`
```js
#if FLAG
window.a = 1;
#else
window.a = 2;
#endif
```
```json
{
"FLAG": true
}
```
will yeild:
```js
window.a = 1;
```
### `if`-`elif`-`else`-`endif`
```js
#if FLAG1
window.a = 1;
#elif FLAG2
window.b = 2;
#else
window.c = 3;
#endif
```
```json
{
"FLAG1": false,
"FLAG2": false
}
```
will yeild:
```js
window.c = 3;
```
## License
MIT © [BinRui.Guan](mailto:differui@gmail.com)