|
Requirement: The modular extension of System.Web.Optimization (also known as Microsoft ASP.NET Web Optimization Framework) that comes with Microsoft ASP.NET MVC is outdated and hasn't been updated for a long time ( last update: 2014/2/20, there are a few bugs that no one has fixed ). bootstrap 4 will report an error, use a third-party Bundle Transformer to replace the default one.
About bundle compression: https: //learn.microsoft.com/en-us/aspnet/mvc/overview/performance/bundling-and-minification
System.Web.Optimization:F:\... \packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll
NuGet Address: https: //www.nuget.org/packages/Microsoft.AspNet.Web.Optimization
System.Web.Optimization will report the following error when bundling and compressing Bootstrap 4:
/* Failed to shrink. Returning unreduced content. (6,10): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,25): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,42): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,59): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,74): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,88): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,105): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,122): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,138): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,153): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,168): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,181): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,196): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,216): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,234): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,254): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,272): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,287): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,305): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,322): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,338): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,353): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,371): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,393): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,415): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,437): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,460): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' (6,644): run-time error CSS1062: Expected semicolon or closing curly-brace, found '-' /*! /*! * Bootstrap v4.1.3 (https://getbootstrap.com/) * Copyright 2011-2018 The Bootstrap Authors * Copyright 2011-2018 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
Bundle Transformer
Bundle Transformer - a modular extension to System.Web.Optimization (also known as the Microsoft ASP.NET Web Optimization Framework). StyleTransformer and ScriptTransformer classes, included in the Bundle Transformer core and implement the IBundleTransform interface. They are intended to replace the standard classes: CssMinify and JsMinify.
Key differences between the StyleTransformer and classes and the standard implementation ScriptTransformer: the ability to exclude unnecessary assets when adding assets from a catalog, no re-shrinking of pre-reduced assets, support for automatic conversion of relative paths to absolute paths in CSS code (by using the UrlRewritingCssPostProcessor), and so on. These classes do not shrink code at runtime, but this can be added by installing minifier-modules (now available modules based on Microsoft Ajax Minifier, YUI Compressor for .NET, NUglify, Google Closure compiler, Douglas Crockford's JSMin, Dean Edwards' Packer, Mihai Bazon's UglifyJS, Sergey Kryzhanovsky's CSSO (CSS Optimizer), WebGrease and Clean-css). Additionally, you can install translation modules that enable intermediate languages (code translation for LESS, Sass, SCSS, CoffeeScript, TypeScript, Mustache (using Hogan) and Handlebars). In addition to this, there is a third type of module in Bundle Transformer - the post-processor. Postprocessors run after the translator and before the compressor. The following postprocessors are now available: URL rewriting CSS postprocessor (included in the core) and a postprocessor module based on Andrey Sitnik's Autoprefixer.
GitHub address: https: //github.com/Taritsyn/BundleTransformer Documentation tutorial: https: //github.com/Taritsyn/BundleTransformer/wiki/Examples-of-usage
BundleTransformer.Core only provides bundling functionality, it does not provide compression and obfuscation features, if you need compression and other features you need to introduce other modules, this article uses the BundleTransformer.NUglify extension module to compress the output of the bundled css and js.
BundleTransformer.NUglify contains two minifier adapters: "NUglifyCssMinifier" (for CSS code minification) and "NUglifyJsMinifier " (for miniaturizing JS code). These adapters perform minification by using NUglify (https://github.com/trullock/NUglify). So, the project can just introduce BundleTransformer.NUglify directly, and the NuGet command is as follows:
After installation, modify the BundleConfig.cs configuration with the following code:
At this point, visit the /Plugins/site/login link, the css resources are not compressed, you still need to modify the configuration of web.config, so that "NUglifyCssMinifier" becomes the default CSS minifier program.
One of them is UrlRewritingCssPostProcessor: it supports automatic conversion of relative paths to absolute paths in CSS code.
Find the /configuration/bundleTransformer/core/css node in the web.config file and change it as follows:
The full configuration looks like this:
(end)
|
Previous: NET/C# application crash abnormal exit automatically generate DMP dump fileNext: NIC virtualization? NIC virtualization technology macvlan details
|