我尝试使用插件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'))
})
答案 0 :(得分:3)
如果您在bower.json
中有依赖关系作为devDependencies,则需要添加“includeDev:true
见
includeDev 类型:mixed默认值:false
您可以通过两种方式包含devDependencies:
将此选项设置为inclusive或true,以将devDependencies添加到&gt;依赖项 或使用exclusive来排除你的依赖
答案 1 :(得分:1)
您需要安装Bower并运行Bower install
所以:
npm install
以使您的项目准备就绪并安装 package.json sudo npm install -g bower
bower install
以复制./bower_components
目录中的 bower.json 依赖项npm install -g gulp
gulp build
gulp serve
并且您已为此做好准备好吧,几乎自动构建......