I have folder with files for different build environment like production,stage, and test. example:
src/config.prod.js
src/config.stage.js
src/config.test.js
what I want is to copy config file based on environment I got, for getting environment name from command i using following code:
var nopt = require('nopt')
, knownOpts = {
"env" : [String, null]
}
, shortHands = {
"test" : ["--env", "test"]
, "dev" : ["--dev", "dev"]
, "stage" : ["--env", "stage"]
, "prod" : ["--env", "prod"]
};
var flags = nopt(knownOpts, shortHands, process.argv, 2);
and when I hit command
gulp build --env dev
I am getting the environment name, now what I want is to copy config file to dist folder(build) based on environment. I have this task for copy file but it copy all files as I don't know how to filter it out.
gulp.task('copyConfig', function(){
gulp.src(['src/*.js'])
.pipe(gulp.dest('dist/'))
})
I am new to gulp, if some one has any suggestion. please help.