Gulp-sourcemaps not creating a sourcemap file?

依然范特西╮ 提交于 2019-12-19 06:39:31

问题


I'm trying to get Gulp sourcemaps to write files, but I can't see these files anywhere. If any new files were created in the working tree, I would see them in git status, but nothing no new files to be found.

Below is my gulpfile.js

var gulp = require('gulp'),
    sourcemaps = require('gulp-sourcemaps'),
    minify = require('gulp-minify'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify');

gulp.task('js', function() {

    return gulp.src('src/js/**/*.js')
        .pipe(sourcemaps.init())
            .pipe(concat('all.js'))
            .pipe(uglify())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./public/js'));
});

Is this correct usage? From the examples I've seen elsewhere, this should be OK. I also see that these plugins are compatable with sourcemaps: https://github.com/floridoo/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support


回答1:


Using the sourcemaps.write() method the way you do appends a source maps line to the all.js file. If you want to write external source map files, you'll need to pass the path to the sourcemaps.write() method:

sourcemaps.write('../maps')

https://www.npmjs.com/package/gulp-sourcemaps



来源:https://stackoverflow.com/questions/33054551/gulp-sourcemaps-not-creating-a-sourcemap-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!