0.0.2 • Published 9 years ago

annotation-loader v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

#annotation-loader

webpack annotation loader

Installation

npm install --save-dev annotation-loader

Usage

for test.js

var foo = {};

/*@bar*/
console.log('bar');
/*@/bar*/

var bar = {};

/*@bar2*/
console.log('bar2');
/*@/bar2*/

with config

var webpack = require('webpack');

module.exports = {
    entry:  './entry.js',
    output: {
        path: __dirname,
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                test: /^.*$/,
                loader: "annotation",
                annotations: [
                    {
                        'for': 'bar',
                        'do': ''
                    },
                    {
                        'for': 'bar2',
                        'do': function (str, $1) {
                            //$1 is content of annotation 
                            return '//annotation removed';
                        }
                    }
                ]
            }
        ]
    }
};

you get

var foo = {};

var bar = {};

//annotation removed

Use for

Use to remove tests exports or some code for dev mode in production

##Licence

MIT