npm

Does your artifact manager get in the way? Join us on Oct. 8 at 10am PT, to discuss how npm can help.Sign up »

rollup-plugin-strip-blocks

1.0.3 • Public • Published

Rollup Strip Block

Rollup plugin to strip blocks of code marked by special comment tags. Useful for removing code that you don't want in your production bundle (e.g. verbose console warnings, etc).

Install:

$ npm install --save-dev rollup-plugin-strip-blocks

or

$ yarn add -D rollup-plugin-strip-blocks

Example:

In your client js source files:

 
var makeFoo(bar, baz) {
    // The following code will be stripped with our plugin
    /* develblock:start */
    if (bar instanceof Bar !== true) {
        throw new Error('makeFoo: bar param is required and must be instance of Bar');
    }
    /* develblock:end */
 
    // This code would remain
    return new Foo(bar, baz);
}
 

In your rollup config, specify the plugin:

// rollup.config.js
import babel from 'rollup-plugin-babel'
import stripblocks from 'rollup-plugin-strip-blocks'
 
export default {
    entry: 'src/main.js',
    dest: 'dist/app.js',
    format: 'iife',
    plugins: [
        stripblocks(),
        babel()
    ]
}

If you want to use custom comment tags to mark the start and end of the block to strip from your code, you can add options for "start" and "end" like this:

// rollup.config.js
import babel from 'rollup-plugin-babel'
import stripblocks from 'rollup-plugin-strip-blocks'
 
export default {
    entry: 'src/main.js',
    dest: 'dist/app.js',
    format: 'iife',
    plugins: [
        stripblocks({
            start: 'DEV-START',
            end: 'DEV-END'
        }),
        babel()
    ]
}

install

npm i rollup-plugin-strip-blocks

Downloadsweekly downloads

1

version

1.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability