这是我的任务
gulp.task('inject', function() {
var wiredep = require('wiredep').stream;
var options = {
bowerJson: require('./bower.json'),
directory: './public/lib'
};
return gulp.src('./src/views/*.html')
.pipe(wiredep(options))
.pipe(gulp.dest('./src/views'));
});
这些是我 bower.json 中的依赖项
"dependencies": {
"bootstrap": "^3.3.7",
"font-awesome": "^4.7.0"
}
当我在命令行中运行“gulp injection”时,它似乎可以工作,但我的依赖项没有出现在 index.html 中。
最佳答案
我尝试使用您发布的完全相同的 gulp 任务进行重现,并且所有文件都已正确注入(inject)。
我没有看到您的 index.html,但检查了您的任务,与我的唯一不同的是 bower 目录。你确定 ./public/lib 也设置在您的 bower.json 文件?
另外,您是否在 html 中添加了这些标签?
<!-- bower:css --> <!-- endbower -->
and
<!-- bower:js --> <!-- endbower -->
This is what my index.html looks like:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- bower:css -->
<!-- endbower -->
<title>Wiredep test</title>
</head>
<body>
<!-- bower:js -->
<!-- endbower -->
</body>
</html>
关于dependency-injection - Wiredep Gulp 依赖注入(inject)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45910351/