Taritsyn/BundleTransformer

Error while compressing Expected semicolon or closing curly-brace, found '-'

jitangupta opened this issue · 4 comments

Getting error when enable optimizations is true.

BundleTable.EnableOptimizations = true;

Similar Issue:
trullock/NUglify#46
Error while compiling the :root
https://github.com/trullock/NUglify/pull/46/files#diff-1fc1d5d1bf6b24928485c0cf59bcd6f7894809d95f5552b52209ca3b222f1b01

Work-around tried unsuccessfully as this also fails when BundleTable.EnableOptimizations = true;
Working as expected when BundleTable.EnableOptimizations = false; (in development mode)

https://stackoverflow.com/a/54088086/8178474

public class MyStyleBundle : Bundle
{
    public MyStyleBundle(string virtualPath) : base(virtualPath, new MyCssMinify())
    {
    }

    public MyStyleBundle(string virtualPath, string cdnPath) : base(virtualPath, cdnPath, new MyCssMinify())
    {
    }
}

public class MyCssMinify : IBundleTransform
{
    internal static readonly MyCssMinify Instance = new MyCssMinify();

    internal static string CssContentType = "text/css";


    public virtual void Process(BundleContext context, BundleResponse response)
    {
        if (context == null)
        {
            throw new ArgumentNullException("context");
        }
        if (response == null)
        {
            throw new ArgumentNullException("response");
        }
        if (!context.EnableInstrumentation)
        {
            // CssCompress.Go- This is your CSS compression implementation
            // You can use the library " Uglify"
            response.Content = Uglify.Css(response.Content);
        }
        response.ContentType = CssContentType;
    }
}

Screen shot:
image

Hello, Jitan!

This is a error at the Microsoft Ajax Minifier library level. Replace the BundleTransformer.MicrosoftAjax module by the BundleTransformer.NUglify module.

If this error still occurs, try to add in the Web.config file the following setting:

<configuration>
  …
  <bundleTransformer …>
    …
    <nuglify>
      <css ignoreErrorList="CSS1062" />
      …
    </nuglify>
    …
  </bundleTransformer>
  …
</configuration>

Thank you for replying @Taritsyn,

I am currently testing the first suggestion.
Sure will add the second one also.

Will update once done

Thank you @Taritsyn,
It is working as expected.