How to use a Gulp file for production and development?

Asked

Viewed 185 times

1

I was researching how to create a Gulp file that understands how to differentiate when it comes to production and when it comes to development. I found the plugin below, and would like to know if this is the ideal way to make this differentiation currently?

https://github.com/gunpowderlabs/gulp-environments

In my research, I found this link below, but since it was created in 2014, I believe this form is outdated or am I wrong? It is a bit like the plugin above because it creates two addresses before.

https://www.justinmccandless.com/post/a-tutorial-for-getting-started-with-gulp/

And if there is any treatment or other plugin I can use in this doubt?

1 answer

0

I figured out a way with the gulp-util:

https://github.com/gulpjs/gulp-util

After you put the const util = require('gulp-util') in the gulpfile.js. file It is possible to create a default task with a production condition to perform another task if you need to:

gulp.task('default', function() {
    if(util.env.prod){
        gulp.start('producao')
    } else {
        gulp.start('desenv')
    }
})

After that, just use the Gulp command at the prompt for production with the same name after the util.env.:

gulp --prod

Browser other questions tagged

You are not signed in. Login or sign up in order to post.