吞咽注射不起作用

吞咽注射不起作用

本文介绍了吞咽注射不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我尝试使用gulp-inject将一些文件注入到PHP文件中。这不起作用。我尝试过使用HTML,但那不起作用。我的控制台中的输出显示gulp-inject 6 files into test.html,但没有注入文件。 #文件是正确的,因为我在我的Gulp文件中查看目录中有6个JavaScript文件。这是我的Guilp任务:

I'm try to use gulp-inject to inject some files into a PHP file. This is not working. I tried using HTML as well but that isn't working. The output in my console says "gulp-inject 6 files into test.html" however there's no files injected. The # of files is correct because I do have 6 JavaScript files in the directory i'm looking at in my Gulp file. Here's my Guilp task:

var inject = require('gulp-inject');

gulp.task('build',function() {

    return gulp.src("src/test.html")
    .pipe(inject(gulp.src("src/vendor/js/*.js")));

});

我的test.html文件如下所示:

My test.html file looks like this:

<!DOCTYPE html>
<html>
<head>
    <title>My index</title>
    <!-- inject:css -->
    <!-- endinject -->
</head>
<body>

<!-- inject:js -->
<!-- endinject -->
</body>
</html>

同样,src / vendor / js目录包含6个文件,控制台中Gulp的输出是称6个文件已添加到test.html,但没有添加任何内容。我的目标是使用PHP来完成这项工作,但没有成功,所以我在这里使用HTML进行测试,仍然没有任何结果。

Again, the src/vendor/js directory contains 6 files and the output from Gulp in the console is saying 6 files were added to test.html, but nothing is added. My goal was to do this with PHP but wasn't working so I was testing here with HTML and still, nothing.

有什么想法?

非常感谢。

推荐答案

这些文件被注入......但只是在内存中!您实际上必须将结果传递给一个文件:

The files were injected...but just in memory ! You actually have to pipe the result to a file :

gulp.task('build',function() {
    return gulp.src("src/test.html")
    .pipe(inject(gulp.src("src/vendor/js/*.js")))
    .pipe(gulp.dest('./dist')); // or .src/ or whatever
});

这篇关于吞咽注射不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:10