Skip to content

Webpack plugin to strip blocks of code marked by special comment tags

License

Notifications You must be signed in to change notification settings

Marc-Andre-Rivet/webpack-preprocessor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webpack Preprocessor

Webpack plugin for preprocessor support

This project is my first attempt at making a webpack loader and is based on the webpack-strip-block project by jballant webpack-strip-block

###Example:

funcion foo() {
    /*#if dev*/
    let bar = 'dev';
    /*#elif stage&&test*/
    let bar = 'stage-test';
    /*#elif stage||test*/
    let bar = 'stage-or-test';
    /*#else*/
    let bar = 'prod';
    /*#endif*/

    /*#if !dev*/
    bar += '!dev';
    /*#endif*/
    
    /*#if cond1&&cond2||cond3 */ // <-- combinations of && and || operators are not supported
    /*#endif*/

    console.log(bar);
}
<!--#if dev||stage-->
<div>DEVELOPMENT VERSION</div>
<!--#endif-->

webpack.config:

{
    module: {
        loaders: [
            { test: /\.(js|htm(l?))$/, loader: "webpack-preprocessor?definitions=['stage,test']" }
        ]
    }
};

About

Webpack plugin to strip blocks of code marked by special comment tags

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%