Home > Web Front-end > JS Tutorial > body text

How to Include \'.min\' Files in Bundler Output?

Linda Hamilton
Release: 2024-10-19 14:57:02
Original
930 people have browsed it

How to Include

Bundler Excludes ".min" Files

The issue encountered is that ASP.NET MVC Bundler does not include files ending with the ".min" extension in its bundled output. This behavior can be frustrating, especially when working with pre-minified JavaScript and CSS files.

In the example code provided, the issue arises when the jquery.tmpl.min.js file is included in a bundle. When the bundle is rendered, only the jquery-1.8.0.js file is included, excluding the ".min" file. This behavior is caused by the default ignore list maintained by the Bundler, which excludes files matching the pattern "*.min.js" when optimization is disabled.

Solution:

To resolve this issue, you can either rename the ".min" files to ".js" or modify the ignore list. Renaming the files is a simple solution, but it can be inconvenient if you have a large number of files to update.

Modifying the ignore list is a more flexible approach. In the BundleConfig class, add the following code to exclude only specific files:

<code class="c#">public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
{
    ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
}

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.IgnoreList.Clear();
    AddDefaultIgnorePatterns(bundles.IgnoreList);

    //...your code
}</code>
Copy after login

This code will ensure that all ".min" files are included in the bundled output, allowing the desired scripts to be rendered correctly.

The above is the detailed content of How to Include \'.min\' Files in Bundler Output?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template