Skip to content

jballant/webpack-strip-assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Webpack Strip Assert

Simple Webpack loader to strip assert statements from your code. This can be useful if you want to use assert statements to provide warnings to developers before they cause bugs later in their code while allowing the code to continue executing in production without throwing errors.

###Example:

In your client js source files:

var assert = require('assert').ok
var Bar = require('Bar');

var makeFoo = function (bar, baz) {
    // The following two lines of code will be stripped with our webpack loader
    assert(bar instanceof Bar, 'bar param must be instance of Bar');
    assert(baz.isOK(), 'baz is not ok!');
    // This code would remain
    return new Foo(bar, baz);
};

In your webpack config:

{
    module: {
        loaders: [
            { test: /\.js$/, loader: "webpack-strip-assert" }
        ]
    }
};

About

Webpack plugin to strip 'assert' statements that are only intended for development purposes

Resources

License

Stars

Watchers

Forks

Packages

No packages published