html - Bower 未将所有 Bower_Component CSS 文件添加到索引

标签 html css gruntjs bower yeoman

所以我有这个 Yeoman Angular fullstack MEAN 元素,我已将 material design 图标 添加到我的 bower_components 中。但是,这不会像我的所有其他 .css 文件一样自动添加到我的 index.html 页面。

有没有办法实现这一点,因为目前每当我启动元素时,我都必须手动添加对 .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.*"
    }
}

最佳答案

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

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

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

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

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

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

相关文章:

php - 调用 php shell_exec 命令的 html 按钮

jquery - Bootstrap 轮播 ("pause")点击按钮时不工作

html - 如果 float div 具有背景 css 属性,为什么不在 float div 的左侧显示框阴影

gruntjs - Karma + PhantomJS + 无法访问互联网

requirejs - 如何从丑化/优化中排除某些 requireJS 文件

html - 中心列大小 - 在调试中调整大小,但找不到后端代码

javascript - localStorage 如何在 Javascript 中运行?

javascript - 将下拉菜单添加到图像按钮

javascript - 添加 typescript 导入可防止编译为单个 js 文件