ASP.NET MVC 4微小&安培;背景图片 [英] ASP.NET MVC 4 Minification & Background Images

查看:147
本文介绍了ASP.NET MVC 4微小&安培;背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用ASP.NET MVC 4 CSS / JavaScript的优化。它的工作原理很好用我自己的CSS / JavaScript的,但我也想与插件使用。每个插件都有自己的文件夹:

I'm currently using ASP.NET MVC 4 CSS/JavaScript Optimizer. It works good with my own CSS/JavaScript, but I also want to use it with plugins. Each plugin has its own folder:

~/Content/css // my own css, ok
~/Content/plugins/rateit
~/Content/plugins/chosen
~/Content/plugins/...

我可以将此文件添加到优化:

I can add this files to optimizer:

var bundle = new Bundle("~/Content/opt", new CssMinify());
...
bundle.AddFile("~/Content/plugins/chosen/chosen.css", "*.css");
BundleTable.Bundles.Add(bundle);

但是,在这种情况下,优化后,CSS是在另一个文件夹和浏览器找不到背景图像了。是否有任何解决方案,自动修改背景图片的CSS路径?

But in this case, after optimization, css is in another folder and browser cannot find background images anymore. Is there any solution to automatically modify css path for background images?

我可以复制所有插件一个文件夹中,但有很多插件,这不是一个好主意。

I can copy all plugins in one folder, but with a lot of plugins, it's not a good idea.

推荐答案

可能有一个看 RequestReduce 。这是另一种基于.NET minifier /捆扎机,它将改写在缩小的/ CSS捆绑所有URL是绝对的。这包括字体和背景图像。它还会自动扩展在CSS的进口。此外,它认为它可以,它会sprite的背景图片。

Might have a look at RequestReduce. It's another .net based minifier/bundler and it will rewrite all urls in the minified/bundled css to be absolute. This includes fonts and background images. It will also automatically expand any imports in the css. Additionally, where it thinks it can, it will sprite the background images.

这篇关于ASP.NET MVC 4微小&安培;背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆