Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using ASP.Net MVC 4 - and attempting to use Toastr too.

I installed it via NuGet - and it works in development, however, when I publish, my Javascript "bundle" reports:

/* Minification failed. Returning unminified contents.
(9908,1-2): run-time warning JS1002: Syntax error: }
 */
/*!
* jQuery JavaScript Library v1.8.3
* http://jquery.com/

My bundle file is:

using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;

namespace BootstrapSupport
{
public class BootstrapBundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/js").Include(
            "~/Scripts/jquery-1.10.1.js",
            //"~/Scripts/jquery-migrate-{version}.js",
            "~/Scripts/bootstrap.js",
            "~/Scripts/jquery.validate.js",
            "~/scripts/jquery.validate.unobtrusive.js",
            "~/Scripts/jquery.validate.unobtrusive-custom-for-bootstrap.js",
            "~/Scripts/jquery.tablesorter.js",
             "~/Scripts/toastr.js",
            "~/Scripts/mt.js"
            ));

        bundles.Add(new StyleBundle("~/content/css").Include(
            "~/Content/bootstrap.css",
            "~/Content/body.css",
            "~/Content/bootstrap-responsive.css",
            "~/Content/bootstrap-mvc-validation.css",
             "~/Content/style.css",
             "~/Content/toastr.css"

            ));
    }
}
}

If I take Toastr out from the bundle above, everything else works fine.

Any idea how I can resolve this problem please?

Thanks, Mark

share|improve this question
    
Hi - this isn't a fix, but a workaround - if I copy the code from toastr.js into the toastr.min.js file - then it works - so it appears there may be a difference between the two files (other than one being minified of course!!) –  Mark Tait Jun 14 '13 at 8:28
    
The behavior you are observing when you rename it to toastr.min.js is because the Bundling & Minification component has the convention of not minifying files that with the pattern *.min.js. That's why you do not see the error come up. It just outputs the file content as is. –  epignosisx Jun 14 '13 at 13:20
add comment

1 Answer

Looks like toastr has some syntax error like missing semicolon, that is affecting the minification process. Here are two things you can try:

  1. Check if there is a newer version of toastr.
  2. Pass the file through http://www.jslint.com or http://jshint.com/ and see what it reveals.

Update: I tried to reproduce your problem with toastr v1.3.1 (downloaded via NuGet) but did not encountered any issues.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.