babel-plugin-prepend

    1.0.2 • Public • Published

    babel-plugin-prepend Build Status

    Babel plugin that allows a statement to be prepended on files during the transformation.

    Install

    With npm do:

    npm i babel-plugin-prepend --D
    

    Usage

    The plugin accepts 2 options:

    • prepend: mandatory option that needs to contain the statement to be prepended during transformation
    • accept: a filter function to accept or deny transformation on files based on the file name

    The prepend option needs to contain 1 single statement.

    If the accept option is not needed, the plugin can be added to .babelrc as follows:

    {
    	"plugins": [
    		[
    			"prepend",
    			{
    				"prepend": "var a = 1;"
    			}
    		]
    	]
    }

    If the 'accept' option is needed, then the plugin needs to be added to babel.config.js as follows:

    {
    	plugins: [
    		[
    			prepend,
    			{
    				prepend: 'var a = 1;',
    				accept: function (filename) {
    					return true;
    				}
    			}
    		]
    	];
    }

    Example

    Input

    var b = 2;

    Output

    var a = 1;
    var b = 2;

    Contributing

    Feel free to submit pull requests. When adding anything new, please remember to update the tests file.

    License

    MIT © Marcos Pont

    Install

    npm i babel-plugin-prepend

    DownloadsWeekly Downloads

    6

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    6.84 kB

    Total Files

    8

    Last publish

    Collaborators

    • avatar