commonjs - gulp, build multiple projects -


i have gulp build process runs through 10 tasks, including browserify , watch. builds common-bundle.js, , common-libs.js. uses browser-sync give me sub-second rebuilds.

now want build project depends on common project. want retain live rebuilds of both common , project work on both of them @ same time. want keep build process dry possible , reuse tasks created build common.

for example, sample task:

var config = require('../config'); gulp.task('styles', function () {   return gulp.src(config.styles.src) // if tell config elsewhere...   ... 

i can't pass parameter each task tell it, go run task use:

var config = require('../config').common; 

vs.

var config = require('../config').projecta; 

i don't think tasks can take parameters.

is there different way structure this? git/gist link highly appreciated.

for trying approach - each task js file has 2 tasks defined, @ least logic of task reused. still wish cleaner.

./gulp/task/style.js:

function styles(config){    return gulp.src(config.styles.src)       ...    } } gulp.task('styles', function () {    styles(config.common); }); gulp.task('stylesproject1', function () {    styles(config.project1); }); 

devtask.js:

runsequence(['styles', 'stylesproject1], 'watch', callback); 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -