c# - Error resolving images when applying both LessBundle & CssRewriteUrlTransform -


i using bootstrap less in mvc application. bundle , minify less, use lessbundle (https://github.com/scott-xu/system.web.optimization.less)

var bundle = new lessbundle("~/css/home").include(             "~/_globalresources/css/language.less"); 

lessbundle working having problem resolve image urls in css. image urls not correct. so, apply cssrewriteurltransform in case fail. image urls not correct.

var bundle = new lessbundle("~/css/home").include(             "~/_globalresources/css/language.less", new cssrewriteurltransform()); 

i try use stylebundle instead of lessbundle recheck cssrewriteurltransform , image urls resolved well.

var bundle = new stylebundle("~/css/home").include(                 "~/_globalresources/css/language.less", new cssrewriteurltransform()); 

i think, using both lessbundle , cssrewriteurltransform give incorrect result.

please me resolve problem archive purpose: bundle less & resolve image urls. thanks.

i fixed problem. download lesstransform , fix this:

public void process(bundlecontext context, bundleresponse bundle)         {             if (context == null)             {                 throw new argumentnullexception("context");             }              if (bundle == null)             {                 throw new argumentnullexception("bundle");             }              context.httpcontext.response.cache.setlastmodifiedfromfiledependencies();              var lessparser = new parser();             var lessengine = this.createlessengine(lessparser);              var content = new stringbuilder(bundle.content.length);              var bundlefiles = new list<bundlefile>();              foreach (var bundlefile in bundle.files)             {                 bundlefiles.add(bundlefile);                 var filepath = bundlefile.includedvirtualpath;                 filepath = filepath.replace('\\', '/');                 if (filepath.startswith("~"))                 {                     filepath = virtualpathutility.toabsolute(filepath);                 }                  if (filepath.startswith("/"))                 {                     filepath = hostingenvironment.mappath(filepath);                 }                  this.setcurrentfilepath(lessparser, filepath);                 var source = file.readalltext(filepath);                 var transformcontent = lessengine.transformtocss(source, filepath);                 foreach (var transform in bundlefile.transforms)                 {                     transformcontent = transform.process(bundlefile.includedvirtualpath, transformcontent);                 }                  content.append(transformcontent);                 content.appendline();                  bundlefiles.addrange(this.getfiledependencies(lessparser, bundlefile.virtualfile));             }              if (bundletable.enableoptimizations)             {                 // include imports in bundle files register cache dependencies                 bundle.files = bundlefiles.distinct();             }              bundle.contenttype = "text/css";             bundle.content = content.tostring();         } 

resolving images works well.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -