Reputation: 1329
I have started a .NET Core Web Api application and I'm using webpack to bundle my javascript and use ES6 features.
However, everytime I make a change and want to see it live I have to run two commands in the VS Code terminal:
webpack
dotnet run
Is there a way to consolidate these two commands into just dotnet run
so that the webpack would get bundled automatically?
As a bonus before I put my Javascript into my web api application, I was able to use the webpack-dev-server and it would automatically run the webpack
command whenever I made changes so I'm curious if there's any way to bundle this functionality into the above as well.
Upvotes: 2
Views: 820
Reputation: 2400
you can execute any scripts as your project build or before publishing by including the script in your .csproj file. For example.
<Target Name="PrepublishScript" BeforeTargets="Publish">
<Exec Command="npm install" />
</Target>
This would install npm packages in your app before publishing.
or in your case
<Target Name="NpmCommands" AfterTargets="Build">
<Exec Command="webpack" />
</Target>
to bundle your files after project build.
Upvotes: 2