在VS2015中执行Gulp.js任务后的构建 [英] Execute Gulp.js tasks post build in VS2015

查看:188
本文介绍了在VS2015中执行Gulp.js任务后的构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本的Asp.Net 5站点,它使用Gulp.JS任务来清理,复制和缩小CSS和JS文件。



任务运行资源管理器 - 一切都很好,旧的脚本被删除,新的复制和文件缩小。



我希望在VS2015中自动执行这些任务 - 所以当我构建项目会发生以下情况:


  • 旧脚本使用干净删除线删除

  • 新脚本包含复制 - 使用复制任务

  • CSS和JS使用min taks缩小(将通过为每个minify调用单独的缩小任务来缩小CSS和JS的大小)(Prod和staging使用缩小版本并且dev使用正常的js和css文件)。


    现在我可能会完全偏离这里,但我会认为在project.json文件我应该可以像这样在脚本配置中调用这些gulp任务:

     scripts:{
    prebuild:[gulp clean],
    postbuild:[gulp copy,gulp min],
    prepublish:[npm install,bower install]

    }

    清理工作完美 - 但是复制和最小任务根本不运行。关于我如何自动执行此行为的任何想法?解决方案

您需要做的就是添加绑定来构建您的步骤gulpfile.js (在第一行)

  ///< binding Clean =' clean'AfterBuild ='postbuild'/> 

之后,您将在Task Runner Explorer中执行以下步骤:



project.json中的脚本部分仅适用于在Visual Studio之外构建 / strong>,同时使用dnu命令:

  dnu build 


I have a basic Asp.Net 5 site which used Gulp.JS tasks to clean, copy and minify CSS and JS files.

When running these tasks in the Task Runner Explorer - all is good and the old scripts are removed, new ones copied and files minified.

I wish to automate these tasks in VS2015 - so when I build the project the following will happen:

  • Old scripts are removed using the clean taks
  • New scripts are copied over - using the copy task
  • CSS and JS are minified using a min taks (will minify CSS and JS by way of calling separate minify tasks for each. (Prod and staging use minified versions and dev uses the normal js and css files).

Now I may be completely off track here but I would have thought that in the project.json file I should be able to call these gulp tasks in the scripts config like so:

"scripts": {
    "prebuild": [ "gulp clean" ],
    "postbuild": ["gulp copy" , "gulp min" ],
    "prepublish": [ "npm install", "bower install"]

}

The clean works perfectly - however the copy and min tasks do not run at all. Any ideas on how I could automate this behaviour please?

解决方案

All you have to do is to add binding to build steps in your gulpfile.js (in the first line):

/// <binding Clean='clean' AfterBuild='postbuild' />

After that, you will have your steps in Task Runner Explorer:

The scripts section in project.json works only for building outside of Visual Studio, while using dnu command:

dnu build

这篇关于在VS2015中执行Gulp.js任务后的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆