1.0.1 • Published 10 years ago

preprocessify v1.0.1

Weekly downloads
475
License
ISC
Repository
github
Last release
10 years ago

preprocessify

A browserify transform that applies preprocess to js files before bundling them.

Example use on the command line

browserify -t [preprocessify --contextFile ./path/to/contextFile.json] entry.js

Example use in a gulp file...

var preprocessify = require('preprocessify');

gulp.task('browserify', function() {
    return browserify('./app/scripts/main.js')
        .transform(preprocessify, {
            includeExtensions: ['.js'],
            context: {"FOO": "bar"} // This will replace "/* @echo FOO */" with "bar"
        })
        .bundle()
        .pipe(source('main.js'))
        .pipe(gulp.dest(config.dist + '/scripts/'));
});

You can use this in combination with konfig to define environment specific variables like this... In ./config/app.json...

{
    "development": {
        "bar": "development bar value"
    },
    "test": {
        "bar": "test bar value"
    },
    "production": {
        "bar": "production bar value"
    }
}

In gulp file...

var config = require('konfig')();
var preprocessify = require('preprocessify');

gulp.task('browserify', function() {
    return browserify('./app/scripts/main.js')
        .transform(preprocessify, {
            includeExtensions: ['.js'],
            context: config.app // When the environment variable NODE_ENV=test, "/* @echo bar */" gets replaced with "test bar value"
        })
        .bundle()
        .pipe(source('main.js'))
        .pipe(gulp.dest(config.dist + '/scripts/'));
});

See also: preprocess and gulp-preprocess

1.0.1

10 years ago

1.0.0

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago