【发布时间】:2015-03-12 15:24:00
【问题描述】:
我刚刚开始使用gulp 和browserify,我需要一些帮助来解决这个问题:
我正在使用一个名为ng-autobootstrap 的库来生成一个browserify 兼容文件,稍后在主脚本中需要该文件。这是我的autobootstrap 任务:
gulp.task "autobootstrap", ->
gulp.src("source/**/*.{coffee,js}",
read: false
base: "source"
)
.pipe(ngAutoBootstrap(
moduleTypes:
animation:
path: "**/animations/*.{coffee,js}",
constant:
path: "**/constants/*.{coffee,js}",
controller:
path: "**/controllers/*.{coffee,js}",
directive:
path: "**/directives/*.{coffee,js}",
factory:
path: "**/factories/*.{coffee,js}",
filter:
path: "**/filters/*.{coffee,js}",
provider:
path: "**/providers/*.{coffee,js}",
service:
path: "**/services/*.{coffee,js}",
value:
path: "**/values/*.{coffee,js}",
# config modules are pulled in like this:
# app.config(require("./path/to-config"))
config:
path: "**/*-config.{coffee,js}"
))
如果我添加.pipe(gulp.dest("./source/")),它将在source 目录中创建一个bootstrap.js 文件,但这不是我想要的,我宁愿保持该目录干净。据我了解,到目前为止,我的内存中有一个黑胶文件,内容如下:
'use strict';
module.exports = function(app) {
// Controllers
app.controller('AppController', require('./controllers/app-controller'));
app.controller('UsersController', require('./controllers/users-controller'));
// ... and so on
};
假设source/js/main.js 文件如下所示:
app = angular.module("app");
require("./bootstrap")(app); // this is the file generated by ng-autobootstrap
还有一个简单的browserify 任务,它创建了build/bundle.js 文件:
browserify = require('browserify')
gulp = require('gulp')
source = require('vinyl-source-stream')
gulp.task 'browserify', ->
browserify('./source/main.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./build/'))
现在,如果我修改autobootstrap 以先将文件写入光盘,然后运行browserify,这一切都很好,./bootstrap 文件将在那里。但是有没有办法避免写入光盘?类似于将乙烯基文件添加到browserify 的搜索树?
【问题讨论】:
标签: javascript angularjs gulp browserify commonjs