Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the proper use of IItemTransform for correcting paths in CSS Bundling with ASP.NET Web Optimization and BundleTransformer?
    primarykey
    data
    text
    <p>I'm presently working on a project that uses the <a href="http://aspnetoptimization.codeplex.com/" rel="nofollow noreferrer">ASP.NET Web Optimization</a> library (v 1.1.0-Beta1) in conjunction with the <a href="http://bundletransformer.codeplex.com/" rel="nofollow noreferrer">Bundle Transformer</a> extension (v 1.7.3-Beta1 for core, 1.7.0-Beta1 for LESS) which is used to convert LESS into CSS. Based on web searches paths within CSS (and less) appear to be a common issue, in most cases it is recommended to manually modify the CSS and be done with it. However, due to differences between our development and production environment, and not <em>owning</em> the affected CSS such a solution is not feasible.</p> <p>Two solutions seem to exist. The first is to overlay the virtual directory as defined by the bundling over the actual directory that contains the content. To me this seems like a poor option.</p> <p>Secondly, and the route I've chosen, is to use a <code>IItemTransform</code> such as <code>CssRewriteUrlTransform</code> (mentioned in <a href="https://stackoverflow.com/a/11386982/1090923">this post</a>. Even this solution has it's <a href="http://aspnetoptimization.codeplex.com/workitem/83" rel="nofollow noreferrer">limitations</a>. As such I've attempted to write my own <code>ItemTransformer</code> but it seems that the results of it's execution is ignored when used in the following manner:</p> <pre><code>public static void RegisterBundles(BundleCollection bundles) { /* among other work pass in IItemTransformer to fix paths */ var styleBundle = new StyleBundle("~/bundles/css/styles") .Include(...) .Include("~/Content/less/font-awesome.less", new RewriteUrlTransform()) .Include(...); styleBundle.Transforms.Add(new CssTransformer()); styleBundle.Orderer = new NullOrderer(); bundles.Add(styleBundle); } </code></pre> <p>Implementation of IItemTransform:</p> <pre><code>public class RewriteUrlTransform : IItemTransform { public string Process(string includedVirtualPath, string input) { return (input manipulated with proper path replacing bad path) } } </code></pre> <p>Unless I'm entirely misunderstanding how an <code>IItemTransform</code> is to be used, which is quite possible due to lack of documentation, I would think that the return of the Process method is the new post processed CSS. However, the return seems to be ignored. The original <em>input</em> is always in use, even when I return a <code>String.Empty()</code>. Am I doing something wrong here or is it indeed a bug?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload