Gulpjs change the file and then re-add it later

There are a few questions like this, but I think my situation is a little different, and I don't seem to understand it.

Given this psuedo code

1.) BaseFolder/*.js except the app.js file
2.) BaseFolder/app/model/*js
3.) BaseFolder/app/store/*.js
4.) BaseFolder/app/view/*.js except Viewport.js
5.) BaseFolder/app/view/Viewport.js
6.) BaseFolder/app/controller/*.js
7.) BaseFolder/app.js

My problem is that I deny the file app.js, for example, I want to add it again at the end. The same goes for the file Viewport.js.

Any ideas how to handle this?

Here is one of the many things I've tried:

var senchaFiles = [
            baseFolderPath + '/*.js',
            '!' + baseFolderPath + '/app.js',
            baseFolderPath + '/app/model/*.js',
            baseFolderPath + '/app/store/*.js',
            baseFolderPath + '/app/view/*.js',
            '!' + baseFolderPath + '/app/view/Viewport.js',
            baseFolderPath + '/app/view/Viewport.js',
            baseFolderPath + '/app/controller/*.js',
            baseFolderPath + '/app.js'
        ];

return gulp.src(senchaFiles)
            .pipe(concat(folder + '.js'))
            // .pipe(sourcemaps.init())
            //.pipe(gulp.dest(JS_DIST_FOLDER))
            // .pipe(uglify())
            // .pipe(rename(folder + '.min.js'))
            // .pipe(sourcemaps.write())
            .pipe(gulp.dest(JS_DIST_FOLDER));
    });

Running this code is not added back to the files app.jsor Viewport.jsthat I denied.

+4
source share
1 answer

Gulp uses node-glob syntax . The code below may be what you are looking for.

var senchaFiles = [
  baseFolderPath + '/!(app)*.js', // all, but app.js
  baseFolderPath + '/app/model/*.js',
  baseFolderPath + '/app/store/*.js',
  baseFolderPath + '/app/view/!(Viewport)*.js', // all, but Viewport.js
  baseFolderPath + '/app/view/Viewport.js',
  baseFolderPath + '/app/controller/*.js',
  baseFolderPath + '/app.js'
];
+5

Source: https://habr.com/ru/post/1568765/


All Articles