rollup-plugin-if

0.1.0 • Public • Published

rollup-plugin-if

Software License Issues JavaScript Style Guide NPM Latest Version

Install

$ npm install rollup-plugin-if -D

Syntax

#[keyword] [expression]

// javascript code goes here

#end[keyword]

Usage

import { rollup } from 'rollup';
import instruction from 'rollup-plugin-if';
 
rollup({
    entry: 'main.js',
    plugins: [
        instruction({
            FLAG1: true,
            FLAG2: true
        })
    ]
}).then(...);

Statements

if

#if FLAG
window.a = 1;
#endif
 
window.b = 2;
{
    "FLAG": true
}

will yeild:

window.a = 1;
window.b = 2;

if-else-endif

#if FLAG
window.a = 1;
#else
window.a = 2;
#endif
{
    "FLAG": true
}

will yeild:

window.a = 1;

if-elif-else-endif

#if FLAG1
window.a = 1;
#elif FLAG2
window.b = 2;
#else
window.c = 3;
#endif
{
    "FLAG1": false,
    "FLAG2": false
}

will yeild:

window.c = 3;

License

MIT © BinRui.Guan

Readme

Keywords

Package Sidebar

Install

npm i rollup-plugin-if

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • differui