This article is a mirror article of machine translation, please click here to jump to the original article.

View: 18761|Reply: 2

[ASP.NET] Asp.net MVC Bundle packages all CSS files together

[Copy link]
Posted on 7/16/2018 5:34:55 PM | | | |
BundleConfig is configured as follows:



The cshtml code looks like this:



If you configure it this way, the page is fine, but it doesn't package all the CSS into one file!

Try using the following configuration:

Since font-awesome needs to load a font file, the page will not display correctly, and the network request will report a 404 error as follows:


Solution

Since the woff2 referenced in the general css is introduced through the relative path, when the bundle compresses the css into a woff2 file, the file cannot be found through the relative path at all, so we need to implement the full path from Xie IItemTransform and paste the code directly:

Then when using the bundle, it looks like this:

In this way, when the bundle compresses the CSS, it will replace the relative path model and process it into a full path. This solves the problem.

Resources:https://stackoverflow.com/questi ... t-virtual-directory




Previous:. NET: OrderBy and ThenBy
Next:webapi exports list data to an Excel table file
 Landlord| Posted on 7/10/2023 6:35:00 PM |
Practical Operation: Use BundleTransformer to replace System.Web.Optimization
https://www.itsvse.com/thread-10387-1-1.html
 Landlord| Posted on 7/10/2023 6:39:46 PM |
EnableOptimizations enabled


If compilationdebug attribute is true, then bundle compressionInvalid


When publishing Web.Release.config removes the debug attribute, as follows:

Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com