GULP:主要的凉亭文件丢失了一些文件

时间:2017-10-27 09:16:20

标签: javascript gulp bower main-bower-files

我使用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"
  }
}




1 个答案:

答案 0 :(得分:0)

我明白了。

看起来需要更多的阅读:你可以通过编辑你的bower.json来为它自己的bower.json中的每个包设置override the "main" files(某些包甚至可能没有bower.json):< / p>

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

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

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