[英]Gulp-Sourcemaps SourcesContent null
Using the following gulp syntax i'm trying to generate map files for our JS for debugging purposes. 我正在尝试使用以下gulp语法为调试目的为我们的JS生成地图文件。
gulp.task('useref', function () {
return gulp.src(['index.html'])
.pipe(addStream.obj(prepareTemplates()))
.pipe(useref())
.pipe(versioning({
'value': version,
'append': {
'key': 'v',
'to': ['css', 'js'],
},
'replaces': [
'#%releasenum%#'
]
}))
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(gulpIf('*.js', uglify()))
.pipe(sourcemaps.write('maps', {
//sourceRoot: '',
sourceMappingURLPrefix: domain,
//debug: true
}))
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('deploy'))
});
All the minification/bundling is done properly, however the map files contain a "sourcesContent:[null]"
which i believe is preventing me from being able to properly use the map files. 所有缩小/捆绑操作"sourcesContent:[null]"
正确完成,但是地图文件包含"sourcesContent:[null]"
,我认为这使我无法正确使用地图文件。
I've been searching non stop but i cannot figure out how to have the map files contain the sourceContent correctly. 我一直在不停地搜索,但是我不知道如何使地图文件正确包含sourceContent。
Our minified js files write to projectroot/deploy/app/* 我们缩小的js文件写入projectroot / deploy / app / *
Our map files write to projectroot/deploy/maps/* 我们的地图文件写入projectroot / deploy / maps / *
The original unminified js files reside in projectroot/app/ . 原始未缩小的js文件位于projectroot / app /中。
When i run the debug:true
on the sourcemaps.write I see: 当我在sourcemaps.write上运行debug:true
时,我看到:
gulp-sourcemap-write: No source content for "app/app.js". Loading from file.
gulp-sourcemap-write: No source content for "app/services.js". Loading from file.
gulp-sourcemap-write: source file not found: C:\tfs\app\services.js
gulp-sourcemap-write: No source content for "app/controllers.js". Loading from file.
gulp-sourcemap-write: source file not found: C:\tfs\app\controllers.js
gulp-sourcemap-write: No source content for "app/directives.js". Loading from file.
gulp-sourcemap-write: source file not found: C:\tfs\app\directives.js
It ended up being gulp-uglify that was causing the issue. 最终导致问题的原因是吞咽不休。 After downgrading to gulp-uglify 1.5.4 everything worked correctly. 降级为gulp-uglify 1.5.4后,一切正常。
Here is more information that helped me solve the problem: https://github.com/terinjokes/gulp-uglify/issues/236 这是帮助我解决问题的更多信息: https : //github.com/terinjokes/gulp-uglify/issues/236
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.