-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sourcemaps into core #843
Comments
Awesome! |
👍 |
2 similar comments
👍 |
👍 |
Does this mean I'll finally be able to merge two streams along with their source maps? |
@nuisanceofcats Example? |
@contra Like: var gulp = require('gulp')
var traceur = require('gulp-traceur')
var concat = require('gulp-concat')
var merge = require('merge-stream')
gulp.task('default', function() {
merge(
gulp.src(['app/*.js', 'app/*/*.js']).pipe(traceur())
gulp.src('bootstrap.js')
)
.pipe(concat('output.js'))
.pipe(gulp.dest('dist/assets'))
}) With full source maps all the way through, the "merge" (or an alternative) would merge the streams and their source maps. |
That should still be possible with the current implementation though, just not as clean |
@contra doesn't seem to be... I tried it like this: var gulp = require('gulp')
var traceur = require('gulp-traceur')
var sourcemaps = require('gulp-sourcemaps')
var concat = require('gulp-concat')
var merge = require('merge-stream')
gulp.task('default', function() {
merge(
gulp.src(['app/*.js', 'app/*/*.js']).pipe(sourcemaps.init()).pipe(traceur())
gulp.src('bootstrap.js').pipe(sourcemaps.init())
)
.pipe(concat('output.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/assets'))
}) But ended up with a bogus source map. I asked on github for help but none was forthcoming so I assumed it wasn't possible. |
That should work... @floridoo any thoughts? |
👍 |
@nuisanceofcats Any luck fixing that? I'm trying to get the same thing working. |
Have been waiting for gulp v4 and experimenting with my own stuff. All node based asset pipelines have major flaws or restrictions, v4 will probably sort it all out. |
Sadly I'm on v4 alpha. Many things still seem to be not perfect. If I am compiling a less file to a css file, the sourcemap will refer to the outputted css file if I'm using multiple sources. Oh well. |
@boogerlad sourcemaps have nothing to do with v4 alpha. This was an issue to discuss implementing the boilerplate into gulp.src/dest. That has pushed off until gulp 4.1 anyway. |
Sorry for going off topic. |
Based on my reading of this thread, there's no way to merge sourcemaps in Gulp v3, and this won't be added until v4.1, which is months away? |
@boogerlad if there is an issue with gulp-sourcemaps then open an issue on gulp-sourcemaps, no point in reporting it on an unrelated issue |
Moving this back to 4.0 since this is pretty easy to do |
@floridoo any thoughts RE merging streams of sourcemaps? |
@contra the source maps are per file, so merging streams should not affect them in theory. maybe the sourcemaps property is dropped by the |
|
@ohjames |
Yep, unfortunately if you merge streams before passing them into concat (e.g. the input streams each use different transformations) then the output source maps are incorrect. I think there is/was a github issue floating around for this. |
My previous comment is incorrect/misleading though, you're right gulp-concat does exactly that... I think. |
@ohjames before we bring this into core I want to make sure that any edge cases are handled. If you have any other concerns/oddities feel free to raise them here |
Added into src on vinyl-fs master, going to do dest later today then make it available for testing on 4.0 👍 gulpjs/vinyl-fs@60685eb |
Cool, anyone else think the default setting for source maps should be true rather than false? |
@contra I tested the merge + concat again with the git master commit, the same test I ran back in my comment from December. It still fails but I found the issue, essentially it's because one of the sources is not transformed (the https://github.com/floridoo/gulp-sourcemaps/blob/master/index.js#L107
|
@ohjames I thought about making it true by default, but I think it makes more sense to opt-in to having more files pop up in the output and more CPU usage |
Looks like this is 50% done (included in |
@phated Just added it into .dest this morning, needs tests and docs though |
Inlining the sourcemaps like this breaks lots of older browsers like IE. If we want to support IE, is there some way to disable this? The behavior I seem to be seeing is that its enabled by default now, which means after updating gulp, lots of older browsers suddenly broke with no obvious fix. Edit Actually not sure what's going on here. I had my calls to |
@joshribakoff Not sure why you are saying it's on by default when that was never said and certainly isn't true |
Also FYI for any interested parties, the sourcemaps option is now available for src and dest on vinyl-fs master. Please test out the changes and I'll cut a release if everything looks good |
im going to close this since it has been implemented, but it still needs testing |
Whats the api for this? |
// How to use native Sourcemaps in Gulp 4 using ES5
var sass = require('gulp-sass');
gulp.task('sass', function() {
return gulp.src('src/styles/main.scss', { sourcemaps: true })
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('site/css', { sourcemaps: true }))
}); In short you need to set Here is a slightly sleeker ES6 way of writing it: // How to use native Sourcemaps in Gulp 4 using ES6
import sass from 'gulp-sass';
const sourcemaps = true;
gulp.task('sass', () => {
return gulp.src('src/styles/main.scss', { sourcemaps })
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('site/css', { sourcemaps }))
}); It outputs the sourcemap inside the CSS file though. Is there a way to output |
Ahh I found the bit of documentation covering how to do external source maps :D https://gulpjs.com/docs/en/api/src#sourcemaps // How to use native external Sourcemaps in Gulp 4
var sass = require('gulp-sass');
gulp.task('sass', function() {
return gulp.src('src/styles/main.scss', { sourcemaps: true })
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('site/css', { sourcemaps: '.' }))
});
|
cc @floridoo
Basically src/dest will have a sourcemap option. Now people don't need to use gulp-sourcemaps in their own files. This will DRY up a ton of stuff
The text was updated successfully, but these errors were encountered: