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 Using Third Party Gulp Libraries

Francis N
Francis N
10,376 Points

Use gulp-useref. if you have scripts located in different locations, it may be difficult to concatenate them in order.

For example, if you have code: <body> <script src="js/lib/a-library.js"></script> <script src="js/lib/another-library.js"></script> <script src="js/main.js"></script> </body>

You can see that you have one script file in the js folder and then a library directory within that js folder with more scripts. With gulp-useref, it detects a comment that starts with "<!--build:" and ends with "<!--endbuild-->". So to use gulp-useref, you just need to do this: <!--build:js js/main.min.js --> <script src="js/lib/a-library.js"></script> <script src="js/lib/another-library.js"></script> <script src="js/main.js"></script> <!-- endbuild -->

and then configure gulp-useref in the gulpfile.

For more information: check out this link https://css-tricks.com/gulp-for-beginners/