Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.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 将文件更改为concat流_Gulp_Gulp Concat - Fatal编程技术网

Gulp 将文件更改为concat流

Gulp 将文件更改为concat流,gulp,gulp-concat,Gulp,Gulp Concat,我用我的gulp文件(dev、uat等)设置了一个多版本,我需要在app.js文件中定义某些变量,然后将它们合并到我的主捆绑包文件中 我不想必须创建编辑过的文件,然后重新编辑该文件。是否可以更改变量,然后将更改后的文件保存在内存中并在concat中使用 gulp.src('_app.js').pipe(replace("'baseURL':", "'baseURL':'www.test.com'")) .pipe(concat(['list of files','file

我用我的gulp文件(dev、uat等)设置了一个多版本,我需要在app.js文件中定义某些变量,然后将它们合并到我的主捆绑包文件中

我不想必须创建编辑过的文件,然后重新编辑该文件。是否可以更改变量,然后将更改后的文件保存在内存中并在concat中使用

gulp.src('_app.js').pipe(replace("'baseURL':", "'baseURL':'www.test.com'"))
            .pipe(concat(['list of files','file in memory']));
您可以使用在
app.js
中进行实际替换,然后使用将其与其他源文件组合:

var replace = require('gulp-replace');
var merge = require('merge-stream');
var order = require('gulp-order');

gulp.task('concat', function() {
  var appStream = gulp.src('app.js')
    .pipe(replace(/'baseURL':/, "'baseURL':'www.test.com'"));
  return merge(appStream, gulp.src(['list of files']))
    .pipe(order(['app.js', '*.js']))
    .pipe(concat('concatenatedFile.js'))
    .pipe(gulp.dest('dist'));
});
您可以使用在
app.js
中进行实际替换,然后使用将其与其他源文件组合:

var replace = require('gulp-replace');
var merge = require('merge-stream');
var order = require('gulp-order');

gulp.task('concat', function() {
  var appStream = gulp.src('app.js')
    .pipe(replace(/'baseURL':/, "'baseURL':'www.test.com'"));
  return merge(appStream, gulp.src(['list of files']))
    .pipe(order(['app.js', '*.js']))
    .pipe(concat('concatenatedFile.js'))
    .pipe(gulp.dest('dist'));
});

谢谢你们,我看了merge,但直到把它放到上下文中,它才对我有意义。再次感谢。如何设置合并的顺序?请签出。我已经用一个例子更新了我的答案,这个例子将
app.js
放在所有其他
.js
文件的前面。我最终使用了gulp StreamQue谢谢你,我看了merge,但直到放到上下文中,它才对我有意义。再次感谢。如何设置合并的顺序?请签出。我用一个例子更新了我的答案,这个例子将
app.js
放在所有其他
.js
文件的前面。我最终使用了gulp streamque