Browserify - 多个入口点 [英] Browserify - multiple entry points

查看:980
本文介绍了Browserify - 多个入口点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一饮而尽内使用Browserify。我想我的测试编译到一个单一的文件中。但是,与我的主要的应用程序,这是我工作得很好,我有麻烦了测试编译。主要的区别是在测试具有多个入口点,存在这样的应用程序不是一个单一的入口点。但我得到的错误来回回Browserify它无法找到切入点。

  browserify =需要'browserify
一饮而尽=需要一饮而尽
来源=需要乙烯基源流gulp.task测试, - >
    browserify
        项:['./app/js/**/*Spec.coffee']
        扩展:['.coffee']
    。束
        调试:真
    .pipe源('specs.js')
    .pipe gulp.dest('./规格/')


解决方案

下面是我是能够建立一个任务似乎解决了问题。基本上我使用外部库以收集文件名作为数组。然后传递数组作为切入点

 使用严格的;无功配置=要求('../配置');
VAR一饮而尽=要求('吞掉');
VAR管道工=要求('一饮而尽-管道工');
VAR水珠=要求('水珠');
VAR browserify =要求('browserify');
无功源=要求('乙烯源流');gulp.task(测试,函数(){
  VAR testFiles = glob.sync('./规格/ ** / * JS');
  返回browserify({
      项:testFiles,
      扩展:['.jsx']
    })
    .bundle({调试:真})
    .pipe(来源(app.js'))
    .pipe(管道工())
    .pipe(gulp.dest(config.dest.development));
});

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 getting the tests to compile. The major difference is the tests have multiple entry points, there isn't one single entry point like that app. But I am getting errors fro Browserify that it can't find the entry point.

browserify   = require 'browserify'
gulp         = require 'gulp'
source       = require 'vinyl-source-stream'

gulp.task 'tests', ->
    browserify
        entries: ['./app/js/**/*Spec.coffee']
        extensions: ['.coffee']
    .bundle 
        debug: true
    .pipe source('specs.js') 
    .pipe gulp.dest('./specs/')

解决方案

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));
});

这篇关于Browserify - 多个入口点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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