1

出于某种原因,我的wiredep 配置正在获取我的bower js 文件,而不是css。

这是我的 gulpfile:

gulp.task('wiredep', function(){

var options = config.getWiredepDefaultOptions();
var wiredep = require('wiredep').stream;

  return gulp
      .src(config.index)
      .pipe($.using())
      .pipe(wiredep(options))
      .pipe($.inject(gulp.src(config.js)))
      .pipe(gulp.dest(config.layout))
});

这是我的 bower.json

    {
  "name": "//",
  "version": "0.0.0",
  "homepage": "//",
  "authors": [
    "//"
  ],
  "description": "//",
  "license": "MIT",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "public/vendor",
    "test",
    "tests"
  ],
  "dependencies": {
    "jquery": "~2.1.4",
    "toastr": "~2.1.1",
    "angular": "~1.4.1",
    "angular-resource": "~1.4.1",
    "angular-route": "~1.4.1",
    "bootstrap": "~3.3.5",
    "angular-mocks": "~1.4.1"
  }
}

我正在使用 Jade 作为模板,JS 正在通过,但 css 没有。

doctype
html
    head

        //bower:css
        //endbower

        base(href="/")
        body(ng-app='app')
        include currentUser
        block main-content

        //bower:js
        script(src='/vendor/jquery/dist/jquery.js')
        script(src='/vendor/toastr/toastr.js')
        script(src='/vendor/angular/angular.js')
        script(src='/vendor/angular-resource/angular-resource.js')
        script(src='/vendor/angular-route/angular-route.js')
        script(src='/vendor/bootstrap/dist/js/bootstrap.js')
        script(src='/vendor/angular-mocks/angular-mocks.js')
        //endbower
4

2 回答 2

0

试试看。

转到 -> bower_components -> bootstrap -> bower.json

修改“main”属性并写入:

[...]

“主”:“dist/css/bootstrap.css”,

[...]

现在可以了。

注意:我删除了 bootstrap.js 的条目,因为我不需要它。

享受 :)

于 2015-07-15T22:23:52.393 回答
0

您的包似乎没有在其 bower.json 文件中正确列出其依赖项。

https://www.npmjs.com/package/wiredep#what-c​​an-go-wrong

您可以在您的 bower.json 中覆盖您的 packages 主属性,如下所示:

在 bower.json

{
  ...
  "dependencies": {
    "package-without-main": "1.0.0"
  },
  "overrides": {
    "bootstrap": {
      "main": ["dist/js/bootstrap.js", "dist/css/bootstrap.css"]
    }
  }
}

https://www.npmjs.com/package/wiredep#bower-overrides

或者在您的有线配置对象中,如下所示:

wiredepOptions: {
    overrides: {
        angular: {
            dependencies: {
                jquery: '^2.2.0'
            }
        },
        bootstrap: {
            main: ["dist/js/bootstrap.js", "dist/css/bootstrap.css"]
        },
        slimScroll: {
            main: 'jquery.slimscroll.js'
        },
        codemirror: {
            main: [
                'lib/codemirror.js',
                'lib/codemirror.css',
                'mode/markdown/markdown.js',
                'mode/javascript/javascript.js',
                'theme/xq-light.css'
            ]
        },
        'font-awesome': {
            main: 'css/font-awesome.css'
        }
    }
}
于 2016-02-04T15:41:05.103 回答