問題描述
我正在嘗試讓 Gulp 源映射來寫入文件,但我無法在任何地方看到這些文件.如果在工作樹中創(chuàng)建了任何新文件,我會在 git status
中看到它們,但沒有找到任何新文件.
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.
下面是我的 gulpfile.js
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'));
});
這是正確的用法嗎?從我在其他地方看到的例子來看,這應該沒問題.我還看到這些插件與源地圖兼容:https://github.com/floridoo/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support
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
推薦答案
使用 sourcemaps.write()
方法,將源映射行附加到 all.js代碼>文件.如果要編寫外部源映射文件,則需要將路徑傳遞給
sourcemaps.write()
方法:
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
這篇關于Gulp-sourcemaps 沒有創(chuàng)建源映射文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!