Correct way to use es6 modularity with gulp + babelify + browserify?

I have to use es6 modularity for my next project, the tools used for building the es6 modularity have been finalised to be gulp,babelify & browserify, I am confused because I am new to all three,& how they work to create es6 modularity. relevant part of my gulp file is

function bundle_js(bundler) {
return bundler.bundle()
    .on('error', map_error)
    .pipe(source('app.js'))
    .pipe(buffer())
    .pipe(gulp.dest('dist/'))
    .pipe(rename('app.min.js'))
    .pipe(sourcemaps.init({ loadMaps: true }))
    // capture sourcemaps from transforms
    .pipe(uglify())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('dist/'))
  }

// Without watchify
gulp.task('browserify', function () {
    var bundler = browserify('app.js', { debug: true }).transform(babelify, {/* options */ })

    return bundle_js(bundler)
})

I want to ask

  • which file should i reference in index.html, app.js or dist/app.min.js

  • there are other js files also in es6 with module export function in js/*js folder, does babelify/browserify uses only entry js file (app.js) or all the src files (js/*js ) for modularity?

  • 链接地址: http://www.djcxy.com/p/32964.html

    上一篇: 装饰师与巴贝尔,意想不到的令牌

    下一篇: 用gulp + babelify + browserify使用es6模块化的正确方法?