简体   繁体   English

main-bower-files gulp返回空数组

[英]main-bower-files gulp returns empty array

I'm trying to use the plugin main-bower-files and it doesn't seem to be able to pull the directory from bower_components. 我正在尝试使用插件main-bower-files ,它似乎无法从bower_components中提取目录。

Its debug message shows it has the right files, but it doesn't return an array 它的调试消息显示它有正确的文件,但它不返回数组

#here you can see the debug finding the places
PackageCollection add        angular bower_components/angular
PackageCollection add        json3 bower_components/json3
PackageCollection add        es5-shim bower_components/es5-shim
PackageCollection add        jquery bower_components/jquery
PackageCollection add        angular-resource bower_components/angular-resource
PackageCollection add        angular-cookies bower_components/angular-cookies
PackageCollection add        angular-sanitize bower_components/angular-sanitize
PackageCollection add        angular-animate bower_components/angular-animate
PackageCollection add        angular-touch bower_components/angular-touch
PackageCollection add        angular-ui-router bower_components/angular-ui-router

[22:25:31] [] #< this is the result of calling require('main-bower-files')()

heres my gulp task for inject 注意我的吞咽任务

var bowerFiles = require('main-bower-files')


gulp.task('inject', function() {
  util.log(bowerFiles({debugging:true}))
  gulp.src('app/index.jade')
    .pipe(jade({pretty: true}))
    .pipe(inject(gulp.src(bowerFiles()), {starttag: '<!-- inject:{{ext}}-->', endtag: '<!-- endinject-->'}))
    .pipe(inject(gulp.src('.tmp/**/*.js', {read: false}), {starttag: '<!-- inject:files:{{ext}}-->', endtag: '<!-- endinject-->'}))
    .pipe(connect.reload())
    .pipe(gulp.dest('.tmp'))
})

If you have dependencies as devDependencies in bower.json you need to add ' includeDev:true 如果你在bower.json有依赖关系作为devDependencies,你需要添加' includeDev:true

see 看到

includeDev Type: mixed Default: false includeDev类型:mixed默认值:false

You can include your devDependencies in two ways: 您可以通过两种方式包含devDependencies:

Set this option to inclusive or true to add the devDependencies to your >dependencies or use exclusive to exclude your dependencies 将此选项设置为inclusive或true可将devDependencies添加到> dependencies或使用exclusive来排除依赖项

You need to install Bower and run Bower install 您需要安装Bower并运行Bower install

So : 所以:

  • Install Node and npm, I guess it's done 安装Node和npm,我猜它已经完成了
  • run npm install to make your project npm ready and install what is in package.json 运行npm install以使你的项目准备好npm并安装package.json中的内容
  • install bower : sudo npm install -g bower 安装凉亭: sudo npm install -g bower
  • run bower install to copy your bower.json dependencies in ./bower_components directory 运行bower install以复制./bower_components目录中的bower.json依赖./bower_components
  • install gulp : npm install -g gulp 安装gulp: npm install -g gulp
  • build your project : gulp build 构建你的项目: gulp build
  • check it out : gulp serve and you're ready for it 检查一下: gulp serve ,你准备好了

Well, almost automatic build... 好吧, 几乎是自动构建......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM