我有以下目录结构:
gulp.task('bower-inject', function () {
gulp.src('./index.html')
.pipe(wiredep())
.pipe(gulp.dest('./'));
});
我有一个gulp任务来注入bower依赖项,如下所示:
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="src/assets/images/favicon.ico">
<title>ABC</title>
<!-- bower:css -->
<!-- endbower -->
<!-- inject:css -->
<!-- this is done with gulp inject which works as expected -->
<!-- endinject -->
</head>
<body ng-controller="AppController as appVm">
<div ui-view></div>
<!-- bower:js -->
<!-- endbower -->
<!-- inject:js -->
<!-- done via gulp-inject and works as expected -->
<!-- endinject -->
</body>
的index.html
"devDependencies": {
"angular": "1.4.0",
"angular-bootstrap": "~0.13.0",
"angular-ui-router": "~0.2.15",
"bootstrap": "~3.3.4",
"modernizr": "~2.8.3",
"font-awesome": "~4.3.0"
}
bower.json
[00:24:50] Starting 'bower-inject'...
[00:24:50] Finished 'bower-inject' after 14 ms
这是我在运行任务时看到的:
.idea/
知道我在这里缺少什么吗?
答案 0 :(得分:2)
这最终对我有用:
gulp.task('inject', function () {
var target = gulp.src('./index.html');
var sources = gulp.src(['src/**/*.js', 'src/**/*.css'], {read: false});
return target
.pipe(wiredep({
devDependencies: true
}))
.pipe(inject(sources))
.pipe(gulp.dest('./'));
});
答案 1 :(得分:0)
当您将软件包作为依赖项安装时,Wiredep将注入脚本标记,而不是dev依赖项。
因此,运行bower install --save angular angular-bootstrap angular-ui-router bootstrap modernizr font-awesome
然后运行gulp build
应该这样做。
注意:某些软件包需要覆盖bower.json
上的配置。 Check here如果您需要,可以获取有关凉亭覆盖的信息。