Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Gulp Basics Gulp your JavaScript Workflow Minifying JavaScript Files

Lionel Sellam
Lionel Sellam
8,683 Points

Going further with gulp

Great video !

Now after completing this, I'm left half, happy half sad. I'm happy that now I can concatenate and minify all my js into one app with gulp, that's great! I'm sad because now I know that gulp is very powerful but I can't use all its power.
You mentionned that you never debug with the minified version, but what if I want to code, and then after testing, I just want to push all my changes on my website without having to change every file I had with ".min" extension ?

I guess my question can be reduced to this: How do you manage your development and production environments without having the hassle to change every file in your HTML with that ".min" extension?

I'm pretty sure Gulp can do this aswell with gulp-rename, meaning by running it, it will automatically change all my files I had previously with the ".min" extension, and then I would only worry about my dev environment, knowing that my code in prod is simply just the concat and minified version.

Thank you,

1 Answer

You could minify/uglify conditionally based on whether the environment is production or development.

This article on Scotch.io has a good example.