当我运行 gulp 命令时,此错误被炸毁
如果你有一些想法如何解决这个问题,我准备好听了))!如果你有一些想法如何解决这个问题,我准备好听了))
> C:\Users\P.A.N.D.E.M.I.C\Desktop\try\gulpfile.js:19
> .pipe(livereload());
> ^ SyntaxError: Unexpected token .
> at createScript (vm.js:56:10)
> at Object.runInThisContext (vm.js:97:10)
> at Module._compile (module.js:542:28)
> at Object.Module._extensions..js (module.js:579:10)
> at Module.load (module.js:487:32)
> at tryModuleLoad (module.js:446:12)
> at Function.Module._load (module.js:438:3)
> at Module.require (module.js:497:17)
> at require (internal/module.js:20:19)
> at Liftoff.handleArguments (C:\Users\P.A.N.D.E.M.I.C\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:116:3)
有 gulpfile.js 的完整代码
var gulp = require('gulp');
var concatCss = require('gulp-concat-css');
var cleanCSS = require('gulp-clean-css');
var concat = require('gulp-concat');
var uglyfly = require('gulp-uglyfly');
var imagemin = require('gulp-imagemin');
var autoprefixer = require('gulp-autoprefixer');
var livereload = require('gulp-livereload');
gulp.task('css', function () {
return gulp.src('static/css/*.css')
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(concatCss("styles/clean.min.css"))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('static/min_css/'));
.pipe(livereload());
});
gulp.task('js', function () {
return gulp.src('static/js/*.js')
.pipe(concat('all.js'))
.pipe(uglyfly())
.pipe(gulp.dest('static/min_js/'));
.pipe(livereload());
});
gulp.task('img', function () {
return gulp.src('static/img/*')
.pipe(imagemin())
.pipe(gulp.dest('static/img/'));
.pipe(livereload());
});
gulp.task('default', function() {
livereload.listen();
gulp.watch('static/css/*.css', ['css']);
gulp.watch('static/js/*.js', ['js']);
gulp.watch('static/img/*', ['img']);
});