html-preprocess-brunch

1.0.0 • Public • Published

preprocessor-brunch

Adds C-style preprocessor directive support to HTML brunch compilations. This allows you to have the same source files, but multiple environments specified in your config-brunch.coffee file to compile for different environments.

Setup

Add "html-preprocess-brunch": "x.y.z" to package.json of your brunch app.

In your brunch-config.coffee file of your brunch app, add a line to specify your buildEnv. In the overrides section, add other environments

It can also be helpful to have different public paths for each config. That way different environments with different buildTarget's will compile their output to different folders.

ex: config-brunch.coffee

exports.config =
  buildEnv: 'debug'
  paths:
    public: 'debug'
  overrides:
    release:
      buildEnv: 'release'
      paths:
        public: 'release'
  ...

Add Directives to Code

Directives for if, else, elseif, and endif are available to control what html gets compiled. Each must be on its own line and prepended by the comment op (<!-- -->).

`<!-- @if (PRODUCTION) -->`
...

`<!-- @elseif (DEBUG) -->`
...

`<!-- @else -->`
...

`<!-- @endif -->`

Note the use of parentheses. Unlike C preprocessor directives, those parentheses are required for @if and @elseif statements.

The @if and @elseif directives also support the OR (||) operator. ex: <!-- @if (PRODUCTION || iOS) -->

  • Nested @if statements are not yet supported.

Compile Your Brunch App

Using the above example, it will compile debug by default and override for release when using the environment variable:

  • brunch build -e release

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    2

Package Sidebar

Install

npm i html-preprocess-brunch

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • walts81