有几个像这样的问题,但我相信我的情况略有不同,我似乎无法弄明白。
给出这个伪代码
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
我的问题是我否定了app.js
文件,然后我想在最后重新添加它。同样处理Viewport.js
文件。
任何想法如何解决这个问题?
这是我尝试过的很多事情之一:
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));
});
运行此代码不会添加回app.js
或{i} Viewport.js
文件中。
答案 0 :(得分:5)
Gulp使用node-glob syntax。以下代码可能是您正在寻找的内容。
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'
];