我正在使用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' }));
});
Run Code Online (Sandbox Code Playgroud)
Tho*_*urg 36
您可以覆盖项目中的角度依赖项bower.json:
https://github.com/ck86/main-bower-files#overrides-options
{
...
"overrides": {
"angular": {
"dependencies": {
"jquery": "~1.8"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我没有使用过main-bower-files,但我能想到的一个技巧是直接包含 jquery 文件,而不将其加载到主 Bower 文件数组中,例如
var glob = ['/path/to/jquery.js'].concat(mainBowerFiles(['**/*.js', '!/path/to/jquery.js']));
var sources = gulp.src(glob);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3882 次 |
| 最近记录: |