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

Source map for minified script that links to original unconcatenated js file

It is possible to have a source map for a minifed concatenated javascript that links back to unconcatenated nonminifed javascript file?

It is possible, just use {loadMaps: true} as a parameter for sourceMaps.init().

This will cause sourceMaps to use the previous sourcemap to create an ultimate sourcemap.

Here it is in use!

gulp.task("concatScripts", function () {
    return gulp.src(["js/jquery.js",
            "js/sticky/jquery.sticky.js",
            "js/main.js"])
            .pipe(sourceMaps.init())
            .pipe(concat("app.js"))
            .pipe(sourceMaps.write("./"))
            .pipe(gulp.dest("js"));
});

gulp.task("minifyScripts", ["concatScripts"], function () {
    return gulp.src('js/app.js')
            .pipe(sourceMaps.init({loadMaps: true}))//This is where it is in use
            .pipe(uglify())
            .pipe(rename("app.min.js"))
            .pipe(sourceMaps.write("./"))
            .pipe(gulp.dest('js'));
});