避免使用 sourceMap 文件
Avoid sourceMap files
这是我的tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "wwwroot/app/source/"
},
"exclude": [
"node_modules",
"bower_components",
"wwwroot",
"typings/main",
"typings/main.d.ts"
]
}
如您所见,sourceMap 选项设置为 true
,这是因为我需要它来调试我的应用程序。
但我只在 调试模式 中需要它,所以当我 运行 我的 发布模式 gulp 脚本。
有什么办法强制--sourceMap=fase
?
你能举出你的 gulp 任务的代码示例吗 - gulp、gulp dist?
我建议您使用插件 gulp-typescript and in gulp watch (default dev task) use him with plugin gulp-sourcemaps。在 gulp dist(或任何任务)中,您只需跳过 gulp-sourcemaps 管道,因此在 dist 版本中,您将没有 sourcemaps。
或者您可以简单地使用两个不同的 tsconfig 文件——dev/prod。并像 gulp-typescript#using-tsconfigjson
这样使用它们
这是我的tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "wwwroot/app/source/"
},
"exclude": [
"node_modules",
"bower_components",
"wwwroot",
"typings/main",
"typings/main.d.ts"
]
}
如您所见,sourceMap 选项设置为 true
,这是因为我需要它来调试我的应用程序。
但我只在 调试模式 中需要它,所以当我 运行 我的 发布模式 gulp 脚本。
有什么办法强制--sourceMap=fase
?
你能举出你的 gulp 任务的代码示例吗 - gulp、gulp dist?
我建议您使用插件 gulp-typescript and in gulp watch (default dev task) use him with plugin gulp-sourcemaps。在 gulp dist(或任何任务)中,您只需跳过 gulp-sourcemaps 管道,因此在 dist 版本中,您将没有 sourcemaps。
或者您可以简单地使用两个不同的 tsconfig 文件——dev/prod。并像 gulp-typescript#using-tsconfigjson
这样使用它们