gpt4 book ai didi

angularjs - Bower 的 Wiredep 不注入(inject)文件

转载 作者:行者123 更新时间:2023-12-02 01:36:27 28 4
gpt4 key购买 nike

我有以下目录结构:

bower_components
node_modules
src
index.html
bower.json
package.json
gulpfile.js
.gitignore

我有一个 gulp 任务来注入(inject) Bower 依赖项,如下所示:

gulp.task('bower-inject', function () {
gulp.src('./index.html')
.pipe(wiredep())
.pipe(gulp.dest('./'));
});

index.html

    <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>

bower.json

"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"
}

这是我在运行任务时看到的:

[00:24:50] 启动“bower-inject”...
[00:24:50] 14 毫秒后完成“bower-inject”

知道我在这里缺少什么吗?

最佳答案

这就是最终对我有用的:

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('./'));
});

关于angularjs - Bower 的 Wiredep 不注入(inject)文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30994584/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com