Skip to main content Link Menu Expand (external link) Document Search Copy Copied


  1. Blind preprocess
  2. Edge cases
  3. Cosmetic one line condition

Blind preprocess

“makes” preprocess doesn’t do full syntax analysis on any structured files (js/html/…), it only blindly matches preprocess directive (@echo/@if/@eval). That’s why following example works:

var name = "/* @echo name */";

Preprocess successfully picked up /* @echo name */ even though it’s inside a JavaScript string literal.

“makes” preprocess knows nothing more than its more syntax.

Edge cases

In rarely cases, you may want “makes” preprocess to ignore some directive literal. For example you want to write a file to the final project for gulp-preprocess (the gulp wrapper of preprocess) to use.

Here we use a trick to use /* @echo na */ to break any @echo/@if/@endif/@eval directive. Because na is not defined in properties, /* @echo na */ will yield to empty string.

For example in

// @/* @echo na */if isProduction
// @/* @echo na */endif

Yield result:

// @if isProduction
// @endif

The @if and @endif directives were reserved.

Cosmetic one line condition

Sometime your one line condition will trigger annoying syntax error in your editor. Like this one:

var target = /* @if no-ie */"es6"/* @endif *//* @if ie */"es3"/* @endif */;

While this is still a correct skeleton file, the cosmetic syntax error in editor is annoying. To help you avoid this small setback, you can use ** instead of */ to close an if clause. This is a feature inherited from original preprocess.

var target = /* @if no-ie **"es6"/* @endif *//* @if ie */"es3"/* @endif */;