Hooman Bahreini
Hooman Bahreini

Reputation: 15549

Getting Syntax error when bundling and minifying Bootstrap 5 CSS Template

I am using a bootstrap 5 template (I have the minified version), which looks like this. This file is generated using gulp: enter image description here

I want to include this file in ASP.NET MVC 5 bundle, as it adds the cache busting version to the URL. MVC bundler tried to minify the file, but I don't know why the minification throws error:

This is MVC bundler produce: enter image description here

This is the error:

Minification failed. Returning unminified contents.

I guess the MVC minification process does not recognize the syntax of my Bootstrap 5 template?

How can I fix this issue? I guess I don't need to minify the file, but I still need to add the cache busting version to the URL.

Upvotes: 0

Views: 103

Answers (1)

Hooman Bahreini
Hooman Bahreini

Reputation: 15549

If you want to Minify and Bundle the stylesheet use StyleBundle class, but if you only want to bundle them without minification then use Bundle class.

bundle:

// the following file is already minified, so use bundle
bundles.Add(new Bundle("~/bundles/css-theme").Include(
    "~/path-to-css/theme.min.css"));

bundling and minify:

// the following file would be minified and them placed in a bundle
bundles.Add(new StyleBundle("~/bundles/css-theme").Include(
    "~/path-to-css/theme.css"));

JavaScript

In case of JavaScript files, you can use ScriptBundle to bundle and minify or just Bundle for bundling.

I found this information here.

Upvotes: 0

Related Questions