【问题标题】:Gulp Plugin OrderGulp 插件顺序
【发布时间】:2015-05-01 16:56:05
【问题描述】:

我正在使用 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:
 *
 * |

【问题讨论】:

    标签: javascript jquery angularjs gulp


    【解决方案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!!'));
    });
    

    【讨论】:

    • 我最初是这样做的,但我遇到了同样的问题,这导致我得到了插件。
    • 很抱歉,尝试检查差异,但没有找到......只有您使用的 plugins.concat
    • 感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多