Adds conditional compilation and compile-time variable replacement support to brunch.
With jscc, you have:
- Conditional inclusion/exclusion of blocks, based on compile-time variables*
- Replacement of variables in the sources, by its value at compile-time
- TypeScript v3 definitions
From v2.8.3, the generation of source map is disabled by default to solve issues with many plugins that does not supports chained source maps. With sourceMaps disabled, jscc will only keep the correct line numbers.
Please read more about this in Using Source Maps.
Install the plugin via npm with
npm i jscc-brunch -D.
or, do manual install:
package.jsonof your brunch app.
- If you want to use git version of plugin, use the GitHub URI
In brunch the order matters and jscc is a preprocessor, so please put it before compilers in the devDependencies of your
Set the options in your
...plugins:jscc:values:_DEBUG: 1_MYAPP: 'My App'...
/*#if _DEBUGconst mylib = require('mylib-debug');//#else */const mylib = ;//#endifmylib;
const mylib = ;mylib;
* jscc has two predefined memvars:
_VERSION, in addition to giving access to the environment variables through the nodejs
See Syntax in the jscc wiki for information about templating.
|escapeQuotes||string||String with the type of quotes to escape in the output of strings: 'single', 'double' or 'both'. This has no default.|
|prefixes||string | RegExp |
|The start of a directive. That is the characters before the '#', usually the start of comments.
|values||object||Plain object defining the variables used by jscc at compile-time.|
|ignore||anymatch||Specify which files in your project should not be processed.
|pattern||RegExp||Regular expression that matches the file paths you want to process.
|sourceMaps||boolean||Enable the generation of sourcemap (if
|sourceMapFor||anymatch||Files for which sourcemap must be generated if
Using Source Maps
You can enable the generation of sourcemap if your are not using JS compilers or your compiler can merge sourcemaps*:
...plugins:jscc:sourceMaps: true // enable sourcemap generation in jsccsourceMapFor: /\.js$/ // allows sourcemap for .js files onlyvalues:_DEBUG: 1_MYAPP: 'My App'...
* The jscc plugin does support merging sourcemaps.
You can read in the jscc Wiki about:
- Date and RegExp types outputs its stringified value (same behavior of the strings).
patternoption defaults to .js, .jsx, .ts and .tsx extensions.
- New option
- Optimized ouput of property values, now you can use more than one property.
- Using jscc v1.1.0
Support my Work
I'm a full-stack developer with more than 20 year of experience and I try to share most of my work for free and help others, but this takes a significant amount of time and effort so, if you like my work, please consider...
Of course, feedback, PRs, and stars are also welcome 🙃
Thanks for your support!
The MIT License (MIT)
Copyright (c) 2016-2018 Alberto Martínez