gulp-order:订购不正确 [英] gulp-order : not Ordering properly

查看:62
本文介绍了gulp-order:订购不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是Gulp的新手,我下载了 gulp-order ,以便在确认 *.js 因为我的某些javascript文件首先需要 jquery 加载.

Gulp newbie here, I downloaded gulp-order for ordering js files when concating *.js because some of my javascript files require jquery to load first.

下面是我的gulpfile.js,其中包含订单,concat,重命名和&丑陋.

Below are my gulpfile.js that have order,concat,rename & uglify.

var date = new Date();
var uniq = date.getTime();

gulp.task('admin-scripts', function() {
    return gulp.src(['assets/admin/js/*.js','!assets/admin/js/respond.min.js','!assets/admin/js/html5shiv.js'])
        .pipe(order([
            "assets/admin/js/jquery.min.js",
            'assets/admin/js/*.js'
        ]))
        .pipe(concat(uniq+'admin.js'))
        .pipe(gulp.dest('build/assets/admin/js/'))
        .pipe(rename(uniq+'admin.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('build/assets/admin/js/'));
});

但是似乎订购不起作用.

But seems the ordering is not working.

排序基于字母 a.js> z.js ,而不是 jquery.min.js> a.js> z.js

the ordering is base on alphabet a.js > z.js instead of jquery.min.js > a.js > z.js

在gulpfile.js上有什么我要写错的代码吗?

is there anything I'd code wrongly on the gulpfile.js?

推荐答案

我的吞咽顺序无法正确排序/无法正常工作的问题是因为我输入了错误的路径,该路径应该相对于 js 文件夹:

The problem my gulp-order not ordering properly / not working is because I'd put wrong path, the path should be relative to the js folder:

正确顺序: jquery.min.js

不正确的顺序: assets/admin/js/jquery.min.js

var date = new Date();
var uniq = date.getTime();

gulp.task('admin-scripts', function() {
    return gulp.src(['assets/admin/js/*.js','!assets/admin/js/respond.min.js','!assets/admin/js/html5shiv.js'])
        .pipe(order([
            "jquery.min.js",
            '*.js'
        ]))
        .pipe(concat(uniq+'admin.js'))
        .pipe(gulp.dest('build/assets/admin/js/'))
        .pipe(rename(uniq+'admin.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('build/assets/admin/js/'));
});

这篇关于gulp-order:订购不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆