main-bower-files gulp返回空数组

时间:2014-07-20 05:30:33

标签: bower gulp gulp-inject

我尝试使用插件main-bower-files并且它似乎无法从bower_components中提取目录。

它的调试消息显示它有正确的文件,但它没有返回数组

#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')()

继承我注入的gulp任务

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'))
})

2 个答案:

答案 0 :(得分:3)

如果您在bower.json中有依赖关系作为devDependencies,则需要添加“includeDev:true

  

includeDev   类型:mixed默认值:false

     

您可以通过两种方式包含devDependencies:

     

将此选项设置为inclusive或true,以将devDependencies添加到&gt;依赖项   或使用exclusive来排除你的依赖

答案 1 :(得分:1)

您需要安装Bower并运行Bower install

所以:

  • 安装Node和npm,我猜它已经完成
  • 运行npm install以使您的项目准备就绪并安装 package.json
  • 中的内容
  • 安装凉亭:sudo npm install -g bower
  • 运行bower install以复制./bower_components目录中的 bower.json 依赖项
  • 安装gulp:npm install -g gulp
  • 构建您的项目:gulp build
  • 检查出来:gulp serve并且您已为此做好准备

好吧,几乎自动构建......