我不能用 wiredep 注入 bower 包并且没有错误?
I can't inject bower packages with wiredep and no error?
我正在尝试将 Bower 包注入 html
使用wiredep,但没有注入,也没有出现错误
这是我的 gulpfile.js:
gulp.task('inject', function () {
var wiredep = require('wiredep').stream;
var options = {
bowerJson: require('./bower.json'), //it will return back that json object
directory: './public/lib' //where to look for
}
return gulp.src('./src/views/*.html')
.pipe(wiredep(options))
.pipe(gulp.dest('./src/views')); // pipe that back into our views directory
});
这是 index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Storystrap Template</title>
<meta name="generator" content="Bootply" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="css/styles.css" rel="stylesheet">
<!-- bower:js -->
<!-- endbower -->
</head>
当我们尝试注入 css 版本在 "bootstrap" 之后的文件时,它不会工作:“3.3.4”
所以我通过覆盖我试图注入的 bower 包来处理它
在我的 bower.json 文件中
这是代码:
"overrides": {
"bootstrap": {
"main": [
"dist/js/bootstrap.js",
"dist/css/bootstrap.css",
"less/bootstrap.less"
]
},
"font-awesome": {
"main": [
"less/font-awesome.less",
"css/font-awesome.min.css",
"scss/font-awesome.scss"
]
}
}
希望对您有所帮助
谢谢。
我正在尝试将 Bower 包注入 html 使用wiredep,但没有注入,也没有出现错误
这是我的 gulpfile.js:
gulp.task('inject', function () {
var wiredep = require('wiredep').stream;
var options = {
bowerJson: require('./bower.json'), //it will return back that json object
directory: './public/lib' //where to look for
}
return gulp.src('./src/views/*.html')
.pipe(wiredep(options))
.pipe(gulp.dest('./src/views')); // pipe that back into our views directory
});
这是 index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Storystrap Template</title>
<meta name="generator" content="Bootply" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="css/styles.css" rel="stylesheet">
<!-- bower:js -->
<!-- endbower -->
</head>
当我们尝试注入 css 版本在 "bootstrap" 之后的文件时,它不会工作:“3.3.4”
所以我通过覆盖我试图注入的 bower 包来处理它 在我的 bower.json 文件中 这是代码:
"overrides": {
"bootstrap": {
"main": [
"dist/js/bootstrap.js",
"dist/css/bootstrap.css",
"less/bootstrap.less"
]
},
"font-awesome": {
"main": [
"less/font-awesome.less",
"css/font-awesome.min.css",
"scss/font-awesome.scss"
]
}
}
希望对您有所帮助 谢谢。