我最近重写了我的 gulpfile,除了保存时,我的主 .coffee 文件将捆绑,但所有必需的文件都不会触发捆绑,我不知道为什么。这是我的文件:
配置文件——
neat = require('node-neat').includePaths
glob = require 'glob'
dest = "../bld"
src = "./src"
module.exports =
browserSync:
proxy: "moovweb.dev/"
ghostMode:
clicks: false
location: false
forms: false
scroll: false
sass:
src: "styl/src/**"
dest: dest
settings:
sourceComments: 'map',
imagePath: '/img',
errLogToConsole: true,
includePaths: ['sass'].concat(neat)
markup:
src: ['../*.php', '../inc/*.php', '../templates/*.php']
images:
src: "/img/**"
dest: dest + "/img"
browserify:
bundleConfigs: [
#entries: glob.sync('./js/src/**/*.coffee')
entries: './js/src/app.coffee'
dest: dest
extensions: ['.coffee']
outputName: 'app.js'
debug: true
]
浏览器化文件——
browserify = require 'browserify'
browserSync = require 'browser-sync'
watchify = require 'watchify'
bundleLogger = require '../util/bundleLogger'
gulp = require 'gulp'
handleErrors = require '../util/handleErrors'
source = require 'vinyl-source-stream'
config = require('../config').browserify
_ = require 'lodash'
browserifyTask = (callback, devMode) ->
bundleQueue = config.bundleConfigs.length
browserifyThis = (bundleConfig) ->
if devMode
_.extend bundleConfig, watchify.args, debug: true
bundleConfig = _.omit bundleConfig, ['external', 'require']
b = browserify(bundleConfig)
bundle = ->
bundleLogger.start(bundleConfig.outputName)
return b
.bundle()
.on 'error', handleErrors
.pipe(source(bundleConfig.outputName))
.pipe(gulp.dest(bundleConfig.dest))
.on 'end', reportFinished
.pipe(browserSync.reload
stream: true
)
b = watchify(b)
b.on 'update', bundle
bundleLogger.watch(bundleConfig.outputName)
reportFinished = ->
bundleLogger.end(bundleConfig.outputName)
if bundleQueue
bundleQueue--
if bundleQueue is 0
callback()
return
return bundle()
config.bundleConfigs.forEach(browserifyThis)
gulp.task 'browserify', browserifyTask
module.exports = browserifyTask
当我保存 app.coffee 时,一切都很好。但是,当我在 app.coffee 中保存任何所需的 .coffee 文件时,除非我重新保存 app.coffee,否则它不会捆绑。我有几个在这样的目录结构中需要的自定义库:
/js
- app.coffee
- /lib
--lib-1.coffee
--lib-2.coffee
--etc.coffee
我已经尝试过 globbing,但这只会产生错误,并且大多数其他所有内容都是在我重新编写它之前设置的。有任何想法吗?