Grunt:不要添加vendor.css引导程序样式,但其他样式

时间:2014-07-31 08:56:10

标签: angularjs gruntjs grunt-build-control

我有一个使用yeoman,grunt和bower的AngularJS项目。它工作正常。我在应用程序中使用了WrapBootstrap个主题之一。所以我不需要AngularJS的默认JQuery和Bootstrap。

在我的index.html页面中,我有以下内容来包含CSS样式。

<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<!-- endbower -->
<!-- endbuild -->
<link href="styles/pagestyle.css" media="all" rel="stylesheet"
    type="text/css" />
    <!-- / bootstrap [required] -->
<link href="assets/stylesheets/bootstrap/bootstrap.css" media="all"
    rel="stylesheet" type="text/css" />
<!-- / theme file [required] -->
<link href="assets/stylesheets/jquery/jquery_ui.css" media="all"
    rel="stylesheet" type="text/css" />
<link href="assets/stylesheets/light-theme.css" media="all"
    id="color-settings-body-color" rel="stylesheet" type="text/css" />
<!-- / coloring file [optional] (if you are going to use custom contrast color) -->
<link href="assets/stylesheets/theme-colors.css" media="all"
    rel="stylesheet" type="text/css" />

我没有在bower_components目录中包含任何CSS。

但当我grunt serve:dist时,它会将 bower_components / dist 目录中的 bootstrap.css 添加到 buld:css 部分。我不想补充一点。所以我从 bower.json 文件中删除了JQuery和bootstrap依赖项。这是我现在的bower.json文件

{
  "name": "app-web-client",
  "version": "0.0.0",
  "dependencies": {
    "angular": "1.2.15",
    "json3": "~3.2.6",
    "es5-shim": "~2.1.0",
    "angular-resource": "1.2.15",
    "angular-cookies": "1.2.15",
    "angular-sanitize": "1.2.15",
    "angular-bootstrap": "0.11.0",
    "angular-route": "1.2.15"
  },
  "devDependencies": {
    "angular-mocks": "1.2.15",
    "angular-scenario": "1.2.15"
  }
}

然后我尝试做grunt发球:dist。我删除了build:css块并且工作正常。

但是当我尝试在build:css块中添加所有这些资源的css样式,并且执行grunt dist时,所有样式都消失了,并且块变为空。它只会这么多,

<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
    <!-- build:css styles/vendor.css -->
    <!-- bower:css -->
    <!-- endbower -->
    <!-- endbuild -->

当在浏览器中打开时,没有应用任何样式,因为它是空的。

如何避免这种情况?我尝试在该块中添加一些其他css。但它正在替换为空块,并给我这个错误。如何从index.html中删除vendor.css。我试过了

1 个答案:

答案 0 :(得分:1)

build:css块实际上是Grunt遵循的指令。从index.html

中删除这四行
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<!-- endbower -->
<!-- endbuild -->

重新运行grunt。您不应再在index.html中引用vendor.css