我正在使用 Gulp 和 main-bower-files 来捆绑我的 bower 依赖项。
我需要确保在 AngularJS 之前包含 jQuery,但是由于 Angular bower 包实际上并不依赖于 jQuery,因此它被包含在之后。
有没有办法将 jQuery 推到源列表的顶部或覆盖 Angular 的依赖项,因此它确实需要 jQuery?
我尝试使用 gulp-order 插件来执行此操作,但它弄乱了剩余文件的原始顺序:
gulp.task('bower', function () {
var sources = gulp.src(mainBowerFiles(['**/*.js', '!**/*.min.js'])); // don't include min files
return sources
// force jquery to be first
.pipe(plugins.order([
'jquery.js',
'*'
]))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.concat('libs.min.js'))
.pipe(plugins.uglify())
.pipe(plugins.sourcemaps.write('./'))
.pipe(gulp.dest(config.output))
.pipe(plugins.notify({ message: 'Bower task complete' }));
});
最佳答案
您可以覆盖项目中的 angulars 依赖项 bower.json
:
https://github.com/ck86/main-bower-files#overrides-options
{
...
"overrides": {
"angular": {
"dependencies": {
"jquery": "~1.8"
}
}
}
}
关于gulp - 控制源文件顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29009439/