0

我正在使用main-bower-files通过 gulp 将文件获取到某个文件夹。但是某些 css 文件丢失了,即使它们位于 bower_components 文件夹中。

例如,来自“pdf.js-viewer”的 CSS 文件 viewer.css 不会被复制,即使来自同一文件夹的 .js 文件也是如此。

知道有什么问题吗?任何提示表示赞赏!

// gulpfile.js: (skipped some unimportant libs etc.
var gutil = require('gulp-util');
var bowerFiles = require('main-bower-files');

var paths = {
  localDev: '/.app'
}

var pipes = {};
pipes.moveBowerStyles = function() {
  gutil.log(bowerFiles()); // this already doesn't have appropriate viewer.css file from the mentioned lib for example (also some other are missing)
	return gulp.src(bowerFiles())
        .pipe(gulp.dest(paths.localDev + '/assets/styles/lib'));
};

gulp.task('default', ['moveBowerStyles']);


// bower.json:
{
  "name": "test",
  "description": "",
  "main": "",
  "license": "MIT",
  "homepage": "",
  "private": true,
  "dependencies": {
    "jquery": "^3.1.0",
    "angular-datatables": "^0.5",
    "angular": "^1.6.4",
    "angular-ui-router": "^1.0.0",
    "bootstrap": "^3.3",
    "font-awesome": "^4.6",
    "font-awesome-animation": "^0.0.9",
    "datatables": "^1.10",
    "angular-route": "^1.5",
    "angular-translate": "^2.12",
    "angular-cookies": "^1.6.4",
    "angular-translate-loader-url": "^2.12",
    "angular-translate-loader-static-files": "^2.12",
    "angular-translate-loader-partial": "^2.12",
    "angular-translate-storage-cookie": "^2.12",
    "angular-bootstrap": "^2.5.0",
    "bower-bootswatch-paper": "paper-less#*",
    "oclazyload": "1.1.0",
    "bower": "*",
    "install": "^1.0",
    "ngsecurity": "^1.6",
    "angular-permission": "^4.0",
    "angular-oauth2": "^4.1.0",
    "angular-schema-form": "^0.8",
    "ng-dialog": "^0.6",
    "bootstrap-select": "^1.11",
    "angular-select2": "^1.5.2",
    "angular-ui-select": "^0.19.8",
    "angular-media-queries": "^0.6",
    "jquery-ui": "^1.12.1",
    "angular-touch": "1.5.0",
    "AngularHammer": "ryanmullins-angular-hammer#^2.2.0",
    "angular-breadcrumb": "^0.5.0",
    "pdf.js-viewer": "^0.3.3",  
    "angular-ui-sortable": "^0.16.1",
    "angular-animate": "1.6.4",
    "angular-file-upload": "^2.5.0",
    "angular-ui-mask": "^1.8.7",
    "angular-inview": "^2.2.0",
    "angular-ui-notification": "^0.3.6",
    "angular-bootstrap-switch": "^0.5.1",
    "bootstrap-switch": "^3.3.4",
    "angular-pdfjs-viewer": "^0.7.4",
    "ui-bootstrap": "angular-ui-bootstrap#^2.5.0",
    "angular-i18n": "^1.6.3",
    "angular-hotkeys": "chieffancypants/angular-hotkeys#^1.7.0",
    "angular-resource": "1.6.4",
    "select2": "^4.0.3",
    "angular-drag-and-drop-lists": "^2.1.0"
  },
  "devDependencies": {
    "angular-translate": "^2.15.1"
  },
  "resolutions": {
    "angular-cookies": "^1.6.4",
    "angular": "^1.6.4",
    "jquery": "^3.1.0",
    "bootstrap-switch": "3.3.2",
    "angular-bootstrap": "^0.10",
    "angular-translate": "^2.15.1",
    "select2": "~3.5.2"
  }
}

4

1 回答 1

0

我想到了。

似乎需要更多阅读:您可以通过像这样编辑 bower.json 来覆盖每个包在其自己的 bower.json 中设置的“主”文件(某些包甚至可能没有 bower.json):

{
   "name": "your-package-name",
   "dependencies": {
      "BOWER-PACKAGE": "*"
   },
   "overrides": {
      "BOWER-PACKAGE": {
        "main": "**/*.js"
      }
   }
}

不知道覆盖实际上允许添加一些未被包标记为主文件的附加文件。(例如,我还需要一个 CSS 和一个包中的图像 - 而不仅仅是 JS 文件)。

如果您检查 bower_components 文件夹(执行“bower install”时得到的)并查找包含您感兴趣的包的文件夹,然后查找 bower.json,您可以看到包的主要文件是什么。

于 2017-10-28T07:04:09.787 回答