Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Webpack Task Runner - how to bind run tasks to Debug and Release

In the Visual Studio Task Runner Explorer, I can bind 'Run - Development' to 'After Build' and this works very well. I can also bind 'Run - Production' to 'After Build' and this will also work.

What I want to be able to do, is have 'Run - Development' execute when I'm in Debug mode, and have 'Run - Production' execute when I'm in Release mode.

How do I make this happen?

like image 611
Bonneville Avatar asked Apr 02 '16 01:04

Bonneville


1 Answers

There's a nuget package that you can install that allows you to run npm commands.

Then you can add two different commands to your package.json file, like so:

"scripts": {
  "webpack": "webpack",
  "webpack-prd": "webpack -p"
},

After having the nuget package installed you edit your .csproj file to run the npm commands configured. Here's how I did:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <NpmCommand>run webpack</NpmCommand>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  <NpmCommand>run webpack-prd</NpmCommand>
</PropertyGroup>
like image 159
thitemple Avatar answered Oct 26 '22 22:10

thitemple