Nukem's Possible Manifestation

    rollup-plugin-bundleutils

    1.2.4 • Public • Published

    rollup-plugin-bundleutils

    NPM Package Build Status Dependencies Dev Dependencies

    A set of functions commonly used after tree shaking.

    Installation

    npm install --save-dev rollup-plugin-bundleutils

    Usage

    // rollup.config.js
    import { timestamp, regex, babel, terser } from 'rollup-plugin-bundleutils';
    
    export default {
        // ...
        plugins: [
            regex([
                [/^import\s.*[\r\n]+/gm, '']
            ]),
            babel({
                compact: false,
                plugins: ['@babel/plugin-proposal-class-properties']
            }),
            terser({
                output: {
                    preamble: `// ${timestamp()}`
                }
            })
        ]
    };

    timestamp

    import { timestamp } from 'rollup-plugin-bundleutils';
    
    console.log(timestamp()); // 2017-09-19 4:55pm

    regex

    JavaScript String replace after tree shaking. Expects an Array of regexp|substr, newSubstr|function pairs.

    // rollup.config.js
    import { regex } from 'rollup-plugin-bundleutils';
    
    export default {
        input: 'src/main.js',
        output: {
            file: 'public/bundle.js',
            format: 'es'
        },
        plugins: [
            regex([
                [/^[\r\n]+export\s.*/gm, '']
            ])
        ]
    };

    babel

    Transpile bundle after tree shaking.

    // rollup.config.js
    import { babel } from 'rollup-plugin-bundleutils';
    
    export default {
        input: 'src/main.js',
        output: {
            file: 'public/bundle.js',
            format: 'iife'
        },
        plugins: [
            babel({
                // Default
                presets: [
                    ['@babel/preset-env', { modules: false }]
                ]
            })
        ]
    };

    terser [uglify|minify]

    Minify bundle after tree shaking.

    // rollup.config.js
    import { terser } from 'rollup-plugin-bundleutils';
    
    export default {
        input: 'src/main.js',
        output: {
            file: 'public/bundle.js',
            format: 'iife'
        },
        plugins: [
            terser()
        ]
    };

    Changelog

    License

    Released under the MIT license.

    Install

    npm i rollup-plugin-bundleutils

    DownloadsWeekly Downloads

    563

    Version

    1.2.4

    License

    MIT

    Unpacked Size

    8.8 kB

    Total Files

    8

    Last publish

    Collaborators

    • pschroen