私が現在開発中のアプリケーションでは、Gulp を学習し、ソース マップを使用しています。アプリケーションは Typescript と Javascript のハイブリッドです。ファイルは連結され、縮小されます。ファイルを渡すときgulp-uglify
にエラーが発生します。
\src\App\node_modules\gulp-uglify\node_modules\vinyl-sourcemaps-apply\node_modules\source-map\lib\source-map\source-map-consumer.js:415
throw new Error('"' + aSource + '" is not in the SourceMap.');
^
Error: "Common.ts" is not in the SourceMap.
at SourceMapConsumer_sourceContentFor [as sourceContentFor] (Z:\Dev\financial-app\src\App\node_modules\gulp-uglify\node_modules\vinyl-sourcemaps-apply\node_modules\source-map\lib\source-map\source-map-consumer.js:415:13)
at SourceMapGenerator.<anonymous> (Z:\Dev\financial-app\src\App\node_modules\gulp-uglify\node_modules\vinyl-sourcemaps-apply\node_modules\source-map\lib\source-map\source-map-generator.js:233:42)
at Array.forEach (native)
これは、 を使用した場合にのみ発生しgulp-sourcemaps
ます。パイプラインでソース マップ生成呼び出しを削除すると、問題は発生しませんが、ソース マップもありません。
return merge(
// TS compile
gulp.src(filePath.appjs.src.ts)
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(sourcemaps.write()),
// JS compile
gulp.src(filePath.appjs.src.js)
)
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat('appscripts.js'))
.pipe(size({ title: 'APPJS' }))
.pipe(sourcemaps.write())
.pipe(gulp.dest(filePath.appjs.dest))
//.pipe(uglify(filePath.uglifyOptions))
.pipe(concat('appscripts.min.js'))
.pipe(size({ title: 'APPJS minified' }))
.pipe(gulp.dest(filePath.appjs.dest));
知っておくと便利かもしれませんが、typescript は に./js/ts/
、javascript は にあり./js/App
ます。