Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jitangupta opened this issue Mar 12, 2021 · 4 comments

Comments

@jitangupta
Copy link

jitangupta commented Mar 12, 2021

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

@Taritsyn
Copy link
Owner

Hello, Jitan!

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

@Taritsyn
Copy link
Owner

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>

@jitangupta
Copy link
Author

Thank you for replying @Taritsyn,

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

Will update once done

@jitangupta
Copy link
Author

Thank you @Taritsyn,
It is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants