A configurable gulp plugin very inspired by gulp-replace that replace enviroment placeholders simply by passing a placeholder config object.
Use npm for install the package
npm install gulp-renvy
In your gulpfile.js import gulp-renvy and call it in a pipe renvy(<placeholder object>,<enviroment:String>)
. For how to define a placeholder object give a look to the following example.
in the gulpfile.js
var renvy = require('gulp-renvy');
var placeholder = {
'BASE_HREF': {'production':'/rejseforsikring/', 'stage':'/rejseforsikring/'},
'RAVEN_DEV': {'production':false, 'stage':true},
'API_PATH_P': {'production':'/api', 'stage':'/api-dev'},
};
// production and stage are the enviroments;
// BASE_HREF, RAVEN_DEV and API_PATH_P are the placeholders that you can place in your html code
gulp.task('html', function(){
return gulp.src(html)
.pipe(renvy(placeholder, 'stage'))
.pipe(gulp.dest('.', { cwd: bases.dist }));
});
...
- tests