我使用Gulp连接我的插件,但它们似乎以错误的顺序缩小,导致我的应用程序崩溃。我正在使用gulp-order插件,我相信我正确使用了它。为了测试,我已经禁用了uglify()。但是,生成的文件始终以Angular开头,而不是jQuery。任何帮助将不胜感激!
...
//Gulp-order to make sure we load things correctly
var order = require('gulp-order');
...
var pluginOrder = [
'src/bower_components/jquery/dist/jquery.js',
'src/bower_components/bootstrap/dist/js/bootstrap.js',
'src/bower_components/angular/angular.js',
'src/bower_components/angular-route/angular-route.js',
'src/bower_components/angular-animate/angular-animate.js',
'src/bower_components/angular-sanitize/angular-sanitize.js',
'src/bower_components/angular-bootstrap/ui-bootstrap.js',
'src/bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
'src/bower_components/**/*.js',
'!src/bower_components/**/*.min.js'
]; //make sure everything loads in the right order
gulp.task('squish-jquery', function() {
return gulp.src( 'src/bower_components/**/*.js' )
.pipe(ignore.exclude([ "**/*.map" ]))
.pipe(order( pluginOrder )).on('error', gutil.log)
//.pipe(plugins.uglify().on('error', gutil.log))
.pipe(plugins.concat('jquery.plugins.min.js'))
.pipe(gulp.dest('build')).on('error', gutil.log);
});
连接文件的开头,jquery.plugins.min.js:
/**
* @license AngularJS v1.3.15
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {'use strict';
/* jshint maxlen: false */
/**
* @ngdoc module
* @name ngAnimate
* @description
*
* The `ngAnimate` module provides support for JavaScript, CSS3 transition and CSS3 keyframe animation hooks within existing core and custom directives.
*
* <div doc-module-components="ngAnimate"></div>
*
* # Usage
*
* To see animations in action, all that is required is to define the appropriate CSS classes
* or to register a JavaScript animation via the `myModule.animation()` function. The directives that support animation automatically are:
* `ngRepeat`, `ngInclude`, `ngIf`, `ngSwitch`, `ngShow`, `ngHide`, `ngView` and `ngClass`. Custom directives can take advantage of animation
* by using the `$animate` service.
*
* Below is a more detailed breakdown of the supported animation events provided by pre-existing ng directives:
*
* |
答案 0 :(得分:1)
我从未使用过gulp-order,但我只是按照这样的连接顺序排序:
gulp.task('js', function(done) {
return gulp.src([
'./bower_components/angular/angular.js',
'./bower_components/angular-bootstrap/ui-bootstrap.js',
'./bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
'./bower_components/angular-collection/angular-collection.js',
'./assets/js/shopApp.js',
'./assets/js/**/*.js'
])
.pipe(concat('all.js'))
//.pipe(uglify())
//.pipe(sourcemaps.write())
.pipe(gulp.dest('public/js/'))
.pipe(notify('js updated!!'));
});