简体   繁体   English

没有办法控制Gulp的顺位顺序吗?

[英]Is there no way to control the concat order of Gulp?

I've tried gulp-order, I've tried renaming files, and most recently I've tried just explicitly listing the scripts in the src like this: 我尝试了口吃顺序,尝试了重命名文件,最近,我尝试了像这样在src中显式列出脚本:

gulp.task('scripts', function(){
  return gulp.src([
    './js/bootstrap.min.js',
    './js/moment-with-locales.min.js',
    './js/jquery.fancybox.min.js'
])
.pipe(concat('bundle.js'))
  .pipe(uglify())
  .pipe(gulp.dest('./dist/'));
})

No matter what I do the output of bundle.js is not following the order that I need. 无论我做什么,bundle.js的输出都不会遵循我所需的顺序。 For what it's worth the order does not change randomly when using concat it is the same order every time. 值得一提的是,使用concat时,顺序不会随机更改,每次都相同。 But it's not alphabetical... 但这不是按字母顺序...

During my research it appears that the issue may be that my gulpfile.js changes are not being applied and I may need to "restart" gulp. 在我的研究期间,似乎是问题出在我的gulpfile.js更改未应用,并且我可能需要“重新启动” gulp。 That being said, I cannot find any information on how to "restart" gulp. 话虽如此,我找不到有关如何“重新启动” gulp的任何信息。

Turns out it wasn't gulp-concat that was changing the order. 事实证明,改变顺序的不是傻瓜式的。 The order was being changed by gulp-uglify. gulp-uglify正在更改顺序。

I was able to solve this problem by doing the uglify before the concat. 通过在连接之前执行uglify,我能够解决此问题。 Like so: 像这样:

gulp.task('scripts', function(){
  return gulp.src([
    './js/bootstrap.min.js',
    './js/moment-with-locales.min.js',
    './js/jquery.fancybox.min.js'
])
  .pipe(uglify())
.pipe(concat('bundle.js'))
  .pipe(gulp.dest('./dist/'));
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM