Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS and JavaScript changes not published to Azure in ASP.NET Core

When I publish a website created with the ASP.NET Core website template to Azure, why are the changes I've made in site.css and site.js not published too?

like image 881
tomRedox Avatar asked Jan 04 '23 04:01

tomRedox


1 Answers

The reason for this is that, despite the presence of the bundleconfig.json file in the solution (which defines that the site.cs and site.js files should be bundled and minified), there isn't actually a minifier installed in the template projects by default, meaning the files site.css.min and site.js.min files are not actually being updated.

You can verify that by expanding the site.css node in the Solution Explorer in VS an comparing site.css to site.min.css.

To get the minification working, you need to add an extension and a NuGet package by doing the following:

  • install the Bundler & Minifier Visual Studio extension
  • Restart Visual Studio
  • Right-click the bundleconfig.json file and select 'Bundler & Minifier' > 'Enable bundle on build'

For more details see Bundling and Minification section of the ASP.NET Core docs.

like image 98
tomRedox Avatar answered Feb 22 '23 23:02

tomRedox