Gulp 4: Built-in Sourcemaps
03 September 2015 by @ddprrt | Posted in: gulp, tools
One really cool feature on the Gulp 4 roadmap is the inclusion of native
sourcemaps. A commit roughly two weeks ago at the vinyl-fs
package makes this possible now. Instead of using the
package directly, you can use a flag in
gulp.src. Gulp takes care of the rest:
gulp.dest takes care of saving those sourcemaps. So with every
command, you get new sourcemaps for your output.
Under the hood, Gulp still uses the
gulp-sourcemaps package. It’s just a
much nicer and more direct way of addressing them. Still, your plugins have
to “understand” Sourcemaps.
At the moment, this is still in Beta. To test it, you have to have Gulp 4 installed:
npm install --save-dev git://github.com/gulpjs/gulp#4.0
node_modules/gulp/ directory, and install the current
npm install --save-dev git://github.com/wearefractal/vinyl-fs
You won’t have to do this anymore once Gulp 4 is public on NPM.
There might be some occasions where you still would need the old plugin. For example, you want to name your source directories to make them easier findable inside your Dev tools. For that, you still have to use the original plugin:
It is also necessary, if you want to combine it with other sourcemaps, like those generated by Browserify:
But since it has the same codebase, you should be fine using them. This is also one of those things that Gulp 4 was constructed on: Things that have proven to be useful, if not mandatory in the past are now getting into core, but still as extractable and reusable as any part of Gulp.
Me again. The Gulp, Yeoman, Bower book is pretty sweet. Just saying.
Comments? Shoot me a tweet!