Dealing with stylesheet limit of 31 in IE8 and older

240 views
Skip to first unread message

Chris

unread,
Sep 5, 2012, 9:28:16 AM9/5/12
to cass...@googlegroups.com
We have more than 32 stylesheets currently included on some of our pages and this breaks in IE8 and older. We could use cassette to bundle these all into one CSS file, but we would like to keep them as separate files when debugging.

Can Cassette be set up to throw an exception if it this occurs? Even better would be if Cassette could support this in the general case by generating dynamic .css files with up to 30 @includes in each (this is the workaround for IE).

Thanks
Chris

Andrew Davey

unread,
Sep 10, 2012, 1:52:24 PM9/10/12
to cass...@googlegroups.com
You could certainly check the bundle.Assets.Count of each bundle in the BundleCollection, and then throw an exception.

Anything more complex than that may be possible but would require a lot of work. It may be simpler to only test IE8 when debug=false, so it only gets the bundled stylesheets.

Richard Ware

unread,
Mar 21, 2013, 7:55:30 AM3/21/13
to cass...@googlegroups.com
I have the same problem.

Is it possible to rig some sort of setup whereby stylesheets are concatenated in debug, but scripts are not? Almost as if debug=false for styles, but =true for scripts?

Andrew Davey

unread,
Mar 21, 2013, 10:52:47 AM3/21/13
to Cassette
You can modify the pipeline used to process bundles. http://getcassette.net/documentation/v2/bundle-pipelines

You need to add Cassette.BundleProcessing.ConcatenateAssets to the bundle pipeline (if in debug mode).

To do this per-bundle, try something like:

bundles.Add<StylesheetBundle>("css", b => b.Pipeline.Add(new ConcatenateAssets { Separator = "\n" });


--
You received this message because you are subscribed to the Google Groups "Cassette" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cassette+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Richard Ware

unread,
Mar 21, 2013, 11:09:52 AM3/21/13
to cass...@googlegroups.com
Thanks for the reply!

Am I right in assuming that this will not work in debug mode? The problem I have is that I will be putting out too many stylesheets for IE (31+) in debug mode, where the stylesheets are not concatenated. Therefore, I would like to concatenate stylesheets in debug mode as well as deploy. However, whilst debugging, I would like JS files to be neither minified or concatenated - so setting debug=false will not work.

Richard Ware

unread,
Mar 21, 2013, 11:12:16 AM3/21/13
to cass...@googlegroups.com
At any rate, when I attempt this approach I get a run time error:

[NotImplementedException: The method or operation is not implemented.] Cassette.BundleProcessing.ConcatenatedAsset.get_Path()

Andrew Davey

unread,
Mar 21, 2013, 1:24:56 PM3/21/13
to Cassette
Ah.. yeah that's a good point! The concatenated asset doesn't have a path so we can't generate a URL for it.

It might be possible to create a better implementation of https://github.com/andrewdavey/cassette/blob/master/src/Cassette/BundleProcessing/ConcatenatedAsset.cs which, for example, has the same path as it's parent bundle. A bit more work than I originally imagined, sorry!



steve baker

unread,
May 14, 2013, 3:00:13 PM5/14/13
to cass...@googlegroups.com
as an alternative approach, is there any way we could pass in the debug setting to be false, but just for the StylesheetBundleProcessor?
ie get settings.IsDebuggingEnabled = false in:

as in effect all we want to do is make stylesheets act like we are always in release mode, but everything else (ie scripts) still act as normal?

or could we get the same effect by telling cassettes pipeline to use the StylesheetHtmlRenderer directly?

Matthew Walter

unread,
Jun 25, 2013, 2:12:47 PM6/25/13
to cass...@googlegroups.com
Hi Steve and Andrew,
Where you guys ever able to get this working?
I am running into the same problem, and this would help a lot.

Cheers,
-matt

Andrew Davey

unread,
Jun 27, 2013, 3:45:40 AM6/27/13
to cass...@googlegroups.com
Please give v2.2.1 a try. The ConcatenatedAsset implementation now supports the Path property, so it can serve up the combined assets even in debug mode.

You'll need to manually tweak the bundle pipeline to make it concat the assets when in debug mode. Something like this:

bundles.Add<StylesheetBundle>("~/css", bundle => {
  if (HttpContext.Current.IsDebuggingEnabled) {
    bundle.Pipeline.Add<ConcatenateAssets>();
  }
});
Reply all
Reply to author
Forward
0 new messages