ASP.NET Core 2 with Bootstrap 4 Bundler Minifier Issue: Expected semicolon or closing curly-brace found '-'

Raymond Tang Raymond Tang 0 3798 1.41 index 1/23/2018

Background

When upgrading Bootstrap to v4.0.0 release, the bundler and minifier doesn’t work properly due to CSS variable is commonly used:

:root{--blue:#007bff;

About 26 errors will show up in the Error List with the following message:

Expected semicolon or closing curly-brace found '-'

https://api.kontext.tech/resource/238b0b9b-ac80-5515-86c7-932971f4c9e7

The environment in my machine has the following setup:

  • VS2017 15.5.4
  • <PackageReference Include="BuildBundlerMinifier" Version="2.6.362" />

Downgrading the package to 2.5.357 doesn't fix the problem in my environment though some people mentioned it can work.

Issue Cause

This issue in BuildBundlerMinifier is caused by another issue in package NUglify:

https://github.com/xoofx/NUglify/issues/17

This issue has not been fixed yet.

It is also raised in GitHub:

https://github.com/madskristensen/BundlerMinifier/issues/295

https://github.com/madskristensen/BundlerMinifier/issues/306

Resolution or Workarounds

Temporary fix

Before this issue is fixed, you can use any of the following approaches to get it work:

  • downgrade your Bootstrap 4 version to beta versions
  • or you change your code temporarily not to minimize bootstrap CSS4 file. You can still bundle and minify your other CSS files which are not using CSS variables.
  • or temporarily manually modify your Bootstrap 4 CSS file to remove that :root section if you are not using bower or other package managers to install those client packages.

I will keep this post updated when the issue is fixed permanently.

bootstrap dotnetcore

Join the Discussion

View or add your thoughts below

Comments