使用Visual Studio 2015检测gulp中的发布/调试 [英] Detect release / debug in gulp using Visual Studio 2015
问题描述
我在Visual Studio中建立了一个ASP.NET 5项目,并创建了一个gulpfile.js,用于构建我的打字稿和少量文件。
对于发布版本,我想uglify和concat我的JavaScript,并为调试我想包括我的输入文件夹中的脚本和地图。
有没有办法'告诉'吞咽当前配置?我已经看到了设置NODE_ENV环境变量的一些提及,但是迄今为止我所见到的解决方案并不是最优的;他们需要在启动IDE之前使用命令行等。
我见过的最接近的解决方案是: http://www.colinsalmcorner.com/post/gulp--workaround-for-handling-vs-solution-configuration 一> 但是,这意味着我不能再使用IDE中内置的Task Runner资源管理器 我的web api在同一个解决方案中有一个单页面角应用。 我使用Debug和Release任务创建了一个gulpfile.js。注意区分大小写的拼写: 仅供参考,我包含gulp-string-replace来处理替换任务: Task Runner Explorer中的任务,我卸载了项目文件并对其进行了编辑,并在结束项目标记之前添加了以下代码: I've set up an ASP.NET 5 project in Visual Studio and created a gulpfile.js which I use to build my typescript and less files. For release builds, I want to uglify and concat my javascripts, and for debug I want to include my typescript- and maps in my output folder. Is there a way to 'tell' gulp the current configuration? I've seen some mention of setting the NODE_ENV environment variable, but thus far the solutions I've seen arent optimal; they require using the command line before starting the IDE, etc. The closest solution I've seen is here: http://www.colinsalmcorner.com/post/gulp--workaround-for-handling-vs-solution-configuration This does, however, mean that I can no longer utilize the Task Runner Explorer which is built-in in the IDE In Visual Studio 2015, with the gulp integration, I like @edo limburg and @RamenChef's answer the best. I have a single page angular app in the same solution as my web api.
When building the SPA, I just wanted to replace the URLs to the API and OAuth2 (OIDC) authority servers in an html and a couple of JavaScript files. I created a gulpfile.js with both a Debug and Release task. Note the case-sensitive spelling: FYI, I included gulp-string-replace to handle the replace tasks: After I tested the tasks in the Task Runner Explorer, I unloaded the project file and edited it, adding the following code right before the end project tag:
这篇关于使用Visual Studio 2015检测gulp中的发布/调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
构建SPA时,我只是想将URL替换为html和一些JavaScript文件中的API和OAuth2(OIDC)授权服务器。
gulp.task('Debug',function(){
gulp.src (./callback.html)
.pipe(替换(uatAuthority,
debugAuthority))
.pipe(gulp.dest('./'));
。 ()。
}
gulp.task('Release',function(){
gulp.src(./ callback.html)
.pipe(replace(debugAuthority,
uatAuthority))
.pipe(gulp.dest('./'));
)
}
var replace = require('gulp-string-replace');
< Target Name =BeforeBuild>
< Exec Command =gulp $(Configuration)/>
< / Target>
gulp.task('Debug', function () {
gulp.src("./callback.html")
.pipe(replace(uatAuthority,
debugAuthority))
.pipe(gulp.dest('./'));
...
}
gulp.task('Release', function () {
gulp.src("./callback.html")
.pipe(replace(debugAuthority,
uatAuthority))
.pipe(gulp.dest('./'));
)
}
var replace = require('gulp-string-replace');
<Target Name="BeforeBuild">
<Exec Command="gulp $(Configuration)" />
</Target>