[英]Bundling css even if using @import
I'm developing an application in C# and Asp.Net MVC. 我正在用C#和Asp.Net MVC开发应用程序。 I have various css files one called base.css
which I then import into other css files using @import
rule as: 我有各种各样的css文件,一个叫做base.css
,然后我使用@import
规则将其导入其他css文件:
@import url('base.css');
Then I bundle my css files to minimise them as: 然后,我将css文件打包以将其最小化为:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
... more css files
So my question is do I have to bundle base.css
even if I'm importing it into a different css? 所以我的问题是,即使我将base.css
导入到另一个CSS中,也必须将其捆绑吗? Because if I don't bunble it then the styling doesn't work as required. 因为如果我不笨拙,则样式将无法按要求工作。
Because the MVC Bundler creates an entirely new file in a potentially different location (see the full path in your bundle name), the location of those import
statements now becomes inaccurate. 由于MVC Bundler在可能不同的位置(请参阅束名称中的完整路径)创建一个全新的文件,因此这些import
语句的位置现在变得不准确。
What you can do instead is to create a separate CSS file (or static declaration on your _Layout
page that includes only those import
statements), and include that outside of any bundle. 相反,您可以做的是创建一个单独的CSS文件(或_Layout
页面上的静态声明,其中仅包含那些import
语句),并将其包含在任何包中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.