我现在感觉有点卡住了。首先我用nuget
安装包 Bootstrap.less
也
安装包无点
然后,如Rick Anderson 的博客文章中关于在 asp.net mvc 中捆绑和缩小所示,我创建了一个 LessTransform-Class。我设置了 2 个几乎为空的 .less 文件并创建了一个新的捆绑包来打包它们......
var lessBundle = new Bundle("~/MyLess").IncludeDirectory("~/Content/MyLess", "*.less", true);
lessBundle.Transforms.Add(new LessTransformer());
lessBundle.Transforms.Add(new CssMinify());
bundles.Add(lessBundle);
效果很好。然后我在主 bootstrap.less 文件中添加了一个新的 StyleBundle(它基本上使用 @import 来包含 bootstrap.less 提供的所有其他 .less 文件)......
bundles.Add(new StyleBundle("~/Bootstrap").Include("~/Content/Bootstrap/less/bootstrap.less"));
和引导 JavaScript 的 ScriptBundle ......
bundles.Add(new ScriptBundle("~/bundles/Bootstrap").Include("~/Scripts/bootstrap/js/bootstrap-*"));
包括所有已发布的 bootstrap-*.js 文件和 TADAA 一切正常。CSS 已编译,包括所有导入的 JavaScript 文件均已正确加载。
但是......所有这些只适用于开发模式
<compilation debug="true" targetFramework="4.5"/>
一旦我禁用调试以查看捆绑到一个文件中并且缩小是否正常工作,我就会遇到问题。
捆绑过程似乎无法将所有这些 .less 文件导入 bootstrap.less
/* Minification failed. Returning unminified contents.
(11,1): run-time error CSS1019: Unexpected token, found '/'
(11,2): run-time error CSS1019: Unexpected token, found '/'
(12,1): run-time error CSS1031: Expected selector, found '@import'
(12,1): run-time error CSS1025: Expected comma or open brace, found '@import'
(12,27): run-time error CSS1019: Unexpected token, found '/'
(12,28): run-time error CSS1019: Unexpected token, found '/'
... here go many many lines like these
(60,25): run-time error CSS1019: Unexpected token, found ';'
(62,1): run-time error CSS1019: Unexpected token, found '/'
(62,2): run-time error CSS1019: Unexpected token, found '/'
(63,1): run-time error CSS1031: Expected selector, found '@import'
(63,1): run-time error CSS1025: Expected comma or open brace, found '@import'
(63,27): run-time error CSS1019: Unexpected token, found '/'
(63,28): run-time error CSS1019: Unexpected token, found '/'
: run-time error CSS1067: Unexpected end of file encountered
*/
/*!
* Bootstrap v2.3.1
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
*/
// Core variables and mixins
@import "variables.less"; // Modify this for custom colors, font-sizes, etc
@import "mixins.less";
... and the rest of the original bootstrap.less... no style definitions
看看缩小的 bootstrap.javascript 包也让我感到困惑。在开发中加载页面后没有问题,现在在谷歌中捆绑和缩小 bootstrap.javascript 后,JavaScript 控制台状态
Uncaught TypeError: Cannot read property 'Constructor' of undefined
我查看了几个似乎与我的问题密切相关的主题,我尝试了一些事情,但到目前为止没有成功。
非常感谢任何可以了解我的情况并指出我遗漏或做错了什么的人。最好的问候,英戈