Asp.net Bundle.config是否可以包含ScriptBundles?
我可以在我的Asp.net Bundle.config是否可以包含ScriptBundles?,asp.net,bundling-and-minification,Asp.net,Bundling And Minification,我可以在我的Bundle.config文件中包含脚本吗,还是只针对样式包 <?xml version="1.0" encoding="utf-8" ?> <bundles version="1.0"> <styleBundle path="~/Content/css"> ... </styleBundle> <scriptBundle path="~/Scripts"> Is this possible?
Bundle.config
文件中包含脚本吗,还是只针对样式包
<?xml version="1.0" encoding="utf-8" ?>
<bundles version="1.0">
<styleBundle path="~/Content/css">
...
</styleBundle>
<scriptBundle path="~/Scripts">
Is this possible?
</scriptBundle>
</bundles>
...
这可能吗?
另外,任何人都可以提供指向Bundle.config
参考的链接,以解释可能的标记和结构吗?我已经搜索过了,但我能找到的只是捆绑的BundleConfig.cs
code方式,而不是标记。我意识到了原因——标记方式更古老,甚至可能被弃用。但是我想学习标记方式,因为它是常见的。我将使用使用旧方法的遗留系统。我和我认为您应该真正避免使用XML表示法。网络上几乎没有关于这个主题的资源。因此,将XML重写为C#可能会更快。但是,有一个包允许您通过XML对其进行配置。该示例可在上找到。这称为“捆绑清单”。这是一个XML文件,位于~/bundle.config
,通过BundleManifest.ReadBundleManifest()加载在应用程序中的code>启动
有一个:
因此,是的,支持scriptBundle
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="BundleConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="include">
<xs:attribute name="path" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="styleBundle">
<xs:sequence>
<xs:element name="include" type="include" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="path" type="xs:string" use="required" />
<xs:attribute name="cdnPath" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="scriptBundle">
<xs:sequence>
<xs:element name="include" type="include" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="path" type="xs:string" use="required" />
<xs:attribute name="cdnPath" type="xs:string" use="optional" />
<xs:attribute name="cdnFallbackExpression" type="xs:string" use="optional" />
</xs:complexType>
<xs:element name="bundles">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element type="styleBundle" name="styleBundle" />
<xs:element type="scriptBundle" name="scriptBundle" />
</xs:choice>
<xs:attribute name="version" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:schema>