Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish only minified versions of JavaScript files (ASPNET Core)

Although there are several articles on this issue, I can't seem to find any that are recent and apply to ASPNET Core 2.x, Visual Studio 2017.

How do I only publish my minified versions of JavaScript (.js) files?

It would be nice to do this via the publish profile (.pubxml) so that I can include/exclude by setting up different publish profiles (Dev, UAT, Staging, Production.

like image 826
paultechguy Avatar asked Sep 03 '25 17:09

paultechguy


1 Answers

Just exclude all .css/.js files and then include .min files. The last rule overrides the previous.

<ItemGroup>
   <Content Update="wwwroot\**\*.css" CopyToPublishDirectory="never" />
   <Content Update="wwwroot\**\*.min.css" CopyToPublishDirectory="always" />
   <Content Update="wwwroot\**\*.js" CopyToPublishDirectory="never" />
   <Content Update="wwwroot\**\*.min.js" CopyToPublishDirectory="always" />
</ItemGroup>
like image 194
Retro Avatar answered Sep 06 '25 10:09

Retro