html - bower 未将所有 bower_component css 文件添加到索引

原文 标签 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.*"
    }
}

最佳答案

您的元素中的依赖项列表中似乎缺少 Material Design 图标 bower.json文件。

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

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

如果你通过命令行安装包,你可以使用 --save将其添加到您的元素依赖项中。

wiredep 的另一个常见问题是缺少包的 bower.json。文件缺少“主要”属性。

关于html - bower 未将所有 bower_component css 文件添加到索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31984610/

相关文章:

html - 修饰符元素的子元素?

css - 如何在 Angular UI Grid 中控制滚动条

javascript - 在Javascript(jQuery)完成之前更新CSS

javascript - grunt-browserify alias 映射两层深

javascript - ERR_ABORTED 404(未找到)-Grunt版本

javascript - react :HTML无法正确呈现

javascript - 选择2个DIV元素

html - 如何在宽度为百分比的li内彼此相邻对齐div

html - 创建网站-完全控制

css - grunt-sass两次调用mixin会导致错误