繁体   English   中英

Babel与Gulp-如何设置JavaScript文件的传输顺序

[英]Babel with Gulp - How to set javascript file transpile order

简而言之,我有一个有角度的应用程序,我想将babel与gulp一起使用来编译我的.js文件。 但是,在dist bundle.js中,它将首先转换控制器,然后转换模块。 因此,我希望babel首先转换.module.js文件,然后再转换.controller.js文件。 这样,我的代码将被正确订购,并且控制器可以正确地附加到模块上。 这是我的gulpfile.js:

const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const babel = require('gulp-babel');
const concat = require('gulp-concat');

gulp.task('default', () => {
    return gulp.src('public/src/**/*.js')
        .pipe(sourcemaps.init())
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(concat('bundle.js'))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('public/dist'));
});

为什么不将模块和控制器分别移动到各自的子文件夹中,而gulp.src依次移动每个文件夹?

使用.src(['foo/', 'bar/'])指定顺序

暂无
暂无

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

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