Closed shadow1runner closed 8 years ago
I feel this is a bit of an edge case which could be solved in how you set up your build scripts. In this case I would probably target different files, so that you can control the includes.
main-vXX.js
or similar for the different build targets...
Possibly you can use yargs
or similar to add some more modularity to your gulp script.
var gulp = require("gulp"),
watch = require("gulp-watch"),
include = require("gulp-include"),
argv = require("yargs").argv;
gulp.task("build", function() {
if (!argv.version) return console.log("No version set, please use --version");
gulp.src("assets-src/js/main-v"+argv.version+".js")
.pipe(include())
.pipe(gulp.dest("assets/js"));
});
You'd then call gulp build --version 1.0
which will build assets-src/js/main-v1.0.js
.
I agree that that's really an edge case and thus shouldn't be part of gulp-include. But the feature I was originally thinking of was more some kind of preprocessor (#ifndef etc.) - but yeah, this is more compiler-related than anything else.
Because I'm in the dilemma right now I'm wondering if other users might have the same use case as I do:
I need to do include code files conditionally (due to different build targets with different instruction set), therefore it would be nice if I could define an environment variable which is passed via e.g.
include( { buildVersion: 1.0})
and I can require or include the files based on a condition.Or does somebody of you guys have a convenient solution for this? Currently I'm looking at gulp-regex-replace to do this job
Thanks