bower不将所有bower_component css文件添加到索引中

时间:2015-08-13 09:38:42

标签: html css gruntjs bower yeoman

所以我有这个Yeoman angular fullstack MEAN项目,我已将material design icons添加到bower_components。但是这不会像我的所有其他index.html文件一样自动添加到我的.css页面。

有没有办法让这种情况发生,因为每当我启动项目时,我都必须手动添加对.css文件的引用。

我的index.html看起来像这样

<head>
    ...

    <!-- build:css(client) app/vendor.css -->
    <!-- bower:css -->
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css" />
    <!-- endbower -->
    <!-- endbuild -->
    <!-- build:css({.tmp,client}) app/app.css -->
    <link rel="stylesheet" href="app/app.css">
    <!-- injector:css -->
    <link rel="stylesheet" href="app/account/login/login.css">
    <link rel="stylesheet" href="app/admin/admin.css">
    <link rel="stylesheet" href="app/app.css">
    <link rel="stylesheet" href="app/impression/impression.css">
    <link rel="stylesheet" href="app/information/information.css">
    <link rel="stylesheet" href="app/main/main.css">
    <link rel="stylesheet" href="app/shop/shop.css">
    <link rel="stylesheet" href="app/turnament/turnament.css">
    <link rel="stylesheet" href="components/modal/modal.css">
    <!-- endinjector -->
    <!-- endbuild -->
</head>

我希望它看起来像这样

<head>
    ...

    <!-- build:css(client) app/vendor.css -->
    <!-- bower:css -->
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css" />
    <link rel="stylesheet" href="bower_components/mdi/css/materialdesignicons.css" />
    <!-- endbower -->

    ...
</head>


修改

bower_component / MDI / bower.json

{
    "name": "mdi",
    "version": "1.1.70",
    "main": [
        "css/materialdesignicons.css",
        "fonts/*",
        "css/*",
        "scss/*",
        "package.json",
        "preview.html"
    ],
    "homepage": "http://materialdesignicons.com",
    "authors": [
        { "name": "Austin Andrews", "homepage": "http://templarian.com" },
        { "name": "Google", "homepage": "http://www.google.com/design" }
    ],
    "license": ["OFL-1.1", "MIT"],
    "ignore": [
        "*.md",
        "*.json"
    ],
    "keywords": [
        "material",
        "design",
        "icons",
        "webfont"
    ]
}


/bower.json

{
    "name": "lunorth",
    "version": "0.0.0",
    "dependencies": {
        "angular": ">=1.2.*",
        "json3": "~3.3.1",
        "es5-shim": "~3.0.1",
        "jquery": "~1.11.0",
        "bootstrap": "~3.1.1",
        "angular-resource": ">=1.2.*",
        "angular-cookies": ">=1.2.*",
        "angular-sanitize": ">=1.2.*",
        "angular-route": ">=1.2.*",
        "angular-bootstrap": "~0.11.0",
        "font-awesome": ">=4.1.0",
        "lodash": "~2.4.1",
        "angular-socket-io": "~0.6.0",
        "angular-animate": "~1.4.2"
    },
    "devDependencies": {
        "angular-mocks": ">=1.2.*",
        "angular-scenario": ">=1.2.*"
    }
}

1 个答案:

答案 0 :(得分:2)

您的项目bower.json文件中的依赖项列表中似乎缺少Material Design Icons。

如果您将名称和版本添加到依赖项中,它将解决您的问题。

"dependencies": {
        "mdi": "1.1.70",
        ...,
        ...
}

如果您通过命令行安装了软件包,则可以使用--save将其添加到项目依赖项中。

wiredep的另一个常见问题是缺少包的bower.json文件缺少'main'属性。