我的项目具有以下结构
.vscode
| |____launch.json
dist
| |____server.js
| |____server.js.map
node_modules
src
| |____server.ts
gulpfile.js
package.json
tsconfig.json
我的launch.json
是
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 9229,
"address": "localhost",
"restart": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"localRoot": "${workspaceRoot}/src/**/*.js",
"remoteRoot": null,
"protocol": "inspector"
}
]
}
我的gulpfile.js
是
const gulp = require('gulp');
const ts = require('gulp-typescript');
const nodemon = require('gulp-nodemon');
const sourcemaps = require('gulp-sourcemaps');
const JSON_FILES = ['src/*.json', 'src/**/*.json'];
// pull in the project TypeScript config
const tsProject = ts.createProject('tsconfig.json');
gulp.task('scripts', () => {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(sourcemaps.write("."))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', ['scripts'], () => {
return gulp.watch('src/**/*.ts', ['scripts']);
});
gulp.task('assets', function () {
return gulp.src(JSON_FILES)
.pipe(gulp.dest('dist'));
});
gulp.task('nodemon', ['scripts', 'assets', 'watch'], () => {
nodemon({
script: './dist/bin/start.js',
nodeArgs: ['--inspect']
});
});
gulp.task('default', ['nodemon']);
我的tsconfig.json
是
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "dist"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
我使用执行npm run startdev
的{{1}}启动我的开发环境。因此,运行gulp
的默认gulp任务,将我的代码编译到nodemon
文件夹。我可以附加调试器,但每当我尝试设置断点时,它都会显示为灰色dist
我认为我的Breakpoint ignored because generated code not found (source map problem?).
配置不正确。我在这里缺少什么?