Adds C-style preprocessor directive support to js brunch compilations.
Adds C-style preprocessor directive support to JS brunch compilations. This allows you to have the same source files, but multiple config.coffee files to compile for different environments.
"jspreprocess-brunch": "x.y.z" to
package.json of your brunch app.
config.coffee file of your brunch app, add a line to specify your
It can also be helpful to have different public paths for each config. That way different configurations with different buildTarget's will compile their output to different folders.
exports.config =buildTarget: 'PRODUCTION'paths:public: 'prod'...
exports.config =buildTarget: 'DEBUG'paths:public: 'debug'...
// #BRUNCH_IF (PRODUCTION)...// #BRUNCH_ELIF (DEBUG)...// #BRUNCH_ELSE...// #BRUNCH_ENDIF
Note the use of parentheses. Unlike C preprocessor directives, those parentheses are required for
#BRUNCH_ELIF directives also support the OR (||) operator.
// #BRUNCH_IF (PRODUCTION || iOS)
#BRUNCH_IFstatements are not yet supported.
Using the config_prod.coffee and config_debug.coffee examples from before, you can compile each config like so:
brunch build -c config_prod
brunch build -c config_debug