我是初学者使用gulp.js,我的网页不受我在index.html文件中所做的更改的影响
我看到了这个错误
server.changed(e.path);
^
TypeError: undefined is not a function
我尝试对gulp-livereload进行更改,但我无法做到。
my gulpfile.js
var gulp = require('gulp'),
gutil = require('gulp-util'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
livereload = require('gulp-livereload'),
lr = require('tiny-lr'),
server = lr();
var jsSources = [
'components/scripts/scriptOne.js',
'components/scripts/scriptTwo.js'
];
gulp.task('js', function() {
gulp.src(jsSources)
.pipe(uglify())
.pipe(concat('script.js'))
.pipe(gulp.dest('js'));
});
gulp.task('watch', function() {
var server = livereload();
gulp.watch(jsSources, ['js']);
gulp.watch(['js/script.js', '*.html'], function(e) {
server.changed(e.path);
});
});
gulp.task('default', ['js', 'watch']);
var gulp = require('gulp'),
gutil = require('gulp-util'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
livereload = require('gulp-livereload'),
lr = require('tiny-lr'),
server = lr();
var jsSources = [
'components/scripts/scriptOne.js',
'components/scripts/scriptTwo.js'
];
gulp.task('js', function() {
gulp.src(jsSources)
.pipe(uglify())
.pipe(concat('script.js'))
.pipe(gulp.dest('js'));
});
gulp.task('watch', function() {
livereload.listen()
var server = livereload();
gulp.watch(jsSources, ['js']);
gulp.watch(['js/script.js', '*.html'], function(e) {
server.changed(e.path);
});
});
gulp.task('default', ['js', 'watch']);
答案 0 :(得分:1)
Gulp插件(如LiveReload)经常更新,在这种情况下,会导致影响Lynda.com课程的细微差别。他们在这里发布了更正: