Search code examples
cssvisual-studiobundlerminify

Bundler & Minifier, CSS Minification Errors on @imports and @keyframes


I'm using Visual Studio 2015 and I just installed Bundler & Minifier extension to minimize HTML, JS and CSS code.

When I ran my project I get a lot of errors.. here I'm showing some of them.

This is en example of my code:

@import url('https://fonts.googleapis.com/css?family=Roboto:300');
@charset "UTF-8";

This are the errors:

@import not allowed here.

@charset not allowed here.

(Bundler & Minifier) Expected expression, found '}'

Do you have any idea to solve this issue?


Solution

  • This answer helped me a lot.

    Minification failed. Returning unminified contents

    @Import must always be first in the CSS document. When you bundle multipule CSS files together, it chains them into a single bundled css file. Since the second css file added to my bundle, in bundle config, contained an @Import at the start, as the files were chained together the @import appeared towards the middle of the newly merged document. Once I changed the bundle order the issue was resolve.