Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
文件注入使用gulp,仅从文件夹中拾取一些文件_Gulp - Fatal编程技术网

文件注入使用gulp,仅从文件夹中拾取一些文件

文件注入使用gulp,仅从文件夹中拾取一些文件,gulp,Gulp,我使用Gulp将js文件注入index.html。我的js资源结构如下: js |-ace-builds |-src |-ace.js |-ext-beautify.js |-ext-chromevox.js |-ext-elastic_tabstops_lite.js |-... |-angular |-angular.js |-angular-ui-ace |-ui-ace.js |-... 问题是,从整个ace builds文件夹中,我

我使用Gulp将js文件注入index.html。我的js资源结构如下:

js
|-ace-builds
  |-src
    |-ace.js
    |-ext-beautify.js
    |-ext-chromevox.js
    |-ext-elastic_tabstops_lite.js
    |-...
|-angular
  |-angular.js
|-angular-ui-ace
  |-ui-ace.js
|-...
问题是,从整个ace builds文件夹中,我只需要插入一个文件ace.js。当然,一个可能的解决方案是手动列出所有注入的文件,但我希望使注入器定义非常紧凑和灵活

问题是:gulp是否可以进行此类文件注入,将文件夹中的其他文件导入,如果可以,如何进行

我尝试了下面的代码,也将(1)和(2)行按相反的顺序放置,但没有成功,没有包括ace.js

gulp.task('index', function () {
    var target = gulp.src('./app/html/index.html');
    var sources = gulp.src([
        'app/js/*.js',
        '!app/js/ace-builds/**/*',                 // (1)
        'app/js/ace-builds/src-noconflict/ace.js'  // (2)
    ], { read: false });
    return target.pipe(inject(sources))
        .pipe(gulp.dest('./app/html'));
});

gulp.src中没有任何内容真正读取ace.js所在的文件夹。为什么不包括app/js/**/ace.js?没有否定。顺便说一下,不管你在哪里列出否定,否定总是最后一个执行。这就是为什么你从来没有拿起ace.js