我在开发过程中打开了2个选项卡(一个带有应用程序,第二个带有jasmine
测试套件)。
所以,我有2个browserify包(看起来像这个代码),所以,我需要两个gulp-livereload
实例工作。我是这样做的:
var livereloadTestSuite = require('gulp-livereload');
var livereloadDeveloperSuite = require('gulp-livereload'); // port 35728
appBundler.bundle()
.on('error', gutil.log)
.pipe(source('application.js'))
.pipe(gulpif(!options.development, streamify(uglify())))
.pipe(gulp.dest(options.dest))
.pipe(gulpif(options.development, livereloadDeveloperSuite())) // this line
.pipe(notify(function () {
console.log('APP bundle built in ' + (Date.now() - start) + 'ms');
}));
testBundler.bundle()
.on('error', gutil.log)
.pipe(source('specs.js'))
.pipe(gulp.dest('./build/'))
.pipe(livereloadTestSuite())
.pipe(notify(function () {
console.log('TEST bundle built in ' + (Date.now() - start) + 'ms');
}));
gulp.task('default', ['buildDependencies'], function () {
livereloadTestSuite.listen();
livereloadDeveloperSuite.listen({ port: 35728, host: 'localhost' });
// calling bundler & testBundler methods
茉莉测试套件有
一行<script src="http://localhost:35729/livereload.js?snipver=1"></script>
app测试套件有这一行
<script src="http://localhost:35728/livereload.js?snipver=1"></script>
Jasmine测试套件在它的rebundle上重新加载成功,但是开发套件根本没有重新加载。我不知道如何解决这个问题
使用删除所需nodejs模块的缓存完成:
var livereloadTestSuite = require('gulp-livereload');
delete(require.cache[require.resolve('gulp-livereload')]);
var livereloadDeveloperSuite = require('gulp-livereload');