How can I set up gulp to run identically in Visual Studio 2017 and msbuild without having to change my build scripts?

后端 未结 3 2108
礼貌的吻别
礼貌的吻别 2021-02-06 00:18

I\'m struggling to get set up with gulp in Visual Studio 2017. I\'m not sure where I\'m going wrong but there are a few things I\'m confused about and I can\'t really find any o

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 00:22

    The way I'm handling this is to first use the Web Essentials 2017 extension. This installs the Bundler & Minifier tool, which then adds a bundleconfig.json file to your project. Right-click on this file, go to the Bundler & Minifier menu item and you will see an option in there to Convert To Gulp.

    Selecting convert to gulp will create the necessary gulpfile.js and also install the npm packages required for using Gulp. Wait for all of the npm packages to install and you can then right click on gulpfile.js, select Task Runner Explorer and you should be ready to set up Gulp-based tasks. If you see gulpfile.js failed to load message, npm packages may still be installing (check the progress bar on the VS 2017 status bar). Hit the Refresh icon in Task Runner Explorer when all packages are installed and the error should vanish.

    There's probably a more manual way to add Gulp support but I find this more automated method ensures all the tooling is wired up to work properly and I don't miss anything.

    I gleaned all this information from the awesome Microsoft Docs site, specifically this page on Bundling & Minification. There's also a Using Gulp section in there that may provide additional details for your situation.

    https://docs.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification

提交回复
热议问题