transfigurify

0.1.2 • Public • Published

transfigurify build status

Configure which browserify transforms get applied to your package via an environment variable.

package.json

{
  "browserify": {
    "transform": [
      "hbsfy",
      "transfigurify"
    ]
  },
  "transfigurify": {
    "test": [
      "brfs"
    ]
  },
  "dependencies": {
    "brfs": "0.0.9",
    "hbsfy": "~0.1.3",
    "transfigurify": "~0.1.0"
  }
}

In this configuration the hbsfy transform runs always, but the brfs transform is applied only if TRANSFIGURIFY_ENV=test, i.e:

TRANSFIGURIFY_ENV=test browserify main.js > bundle.js

Examples

Please review and try this full example to get a better understanding of how transfigurify works.

Reading the tests is also benefitial to that end.

Installation

npm install transfigurify

API

transfigurify::env

The env variable which is used by transfigurify to determine which transforms config in the package.json to use in order to apply transforms.

You need to set this or provide it via the TRANSFIGURIFY_ENV environment variable.

// setting from javascript
transfigurify.env = 'test';
# setting from command line
TRANSFIGURIFY_ENV=test browserify -t transfigurify ...
Source:

transfigurify(file) → {TransformStream}

browserify transform which applies a set of browserify transforms that are configured inside package.json. Multiple sets can be configured and a matching one selected depending on the TRANSFIGURIFY_ENV environment variable.

This variable can also be set directly via transfigurify.env='x'.

If no matching configuration is found or the environment variable wasn't set a through stream is returned which means that the file will not be transformed by transfigurify.

Parameters:
Name Type Description
file string

file whose content is to be transformed

Source:
Returns:

transform that is composed of the transforms that were configured for the environment (if any)

Type
TransformStream

generated with docme

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i transfigurify

Weekly Downloads

1

Version

0.1.2

License

MIT

Last publish

Collaborators

  • thlorenz