次のように私のディレクトリ構造は次のとおりです。以下に示すように一息-注入はindex.htmlの中のjsファイルを注入することができません
|- app
|- bower_components
|- css
|- img
|- js
|- scss
|- template
|- node_modules
|- gulpfile.js
|- package.json
|- .bowerrc
|- bower.json
今私のgulpfile.jsは次のとおりです。
gulp.task('index', function() {
var target = gulp.src('./app/index.html');
var sources = gulp.src(['app/js/**/*.js'], { read: false });
return target.pipe(inject(sources))
.pipe(gulp.dest('app/js'));
});
gulp.task('default', function(callback) {
runSequence(['sass', 'browserSync', 'index'], 'watch',
callback
);
});
マイ指数一息経由
<!DOCTYPE html>
<html>
<head>
<title>kisanApp</title>
<!-- inject:css -->
<!-- endinject -->
</head>
<body ng-app="kisanApp">
<ng-view></ng-view>
<!-- inject:js -->
<!-- endinject -->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
</body>
</html>
しかし、どういうわけか、私のjsファイルはindex.htmlの中に追加されません:.htmlのファイルは、以下の通りです。パスに何か問題がありますか?
それ追加** <スクリプトSRC = "/アプリ/ JS/app.js "> ** ** ** –
ではなく、var sources = gulp.src(['。/ app/js/**/*。js'] {ref:false}、{relative:true}); ref:https://github.com/klei/gulp-inject/wiki/Clarifying-injected-paths – dCrux
あなたのコードを試しました。出来た! –