Browserify - multiple entry points

前端 未结 4 1537
夕颜
夕颜 2020-12-13 18:55

I am using Browserify within gulp. I am trying to compile down my tests to a single file as well. But unlike my main app, which I have working just fine, I am having trouble

4条回答
  •  春和景丽
    2020-12-13 19:03

    Below is a task I was able to build that seems to solve the problem. Basically I use an outside library to gather the files names as an array. And then pass that array as the entry points

    'use strict;'
    
    var config = require('../config');
    var gulp = require('gulp');
    var plumber = require('gulp-plumber');
    var glob = require('glob');
    var browserify  = require('browserify');
    var source = require('vinyl-source-stream');
    
    gulp.task('tests', function(){
      var testFiles = glob.sync('./spec/**/*.js');
      return browserify({
          entries: testFiles,
          extensions: ['.jsx']
        })
        .bundle({debug: true})
        .pipe(source('app.js'))
        .pipe(plumber())
        .pipe(gulp.dest(config.dest.development));
    });
    

提交回复
热议问题