Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp - error SyntaxError: Unexpected token

I am trying to understand Gulp. I am on a Windows platform.

I have a simple gulpfile.js - but I keep getting

SyntaxError. Unexpected token/identifier

I think it is saying identifier gulp is wrong but not sure. If it is, I'm not sure how I should set-up the gulpfile or what identifier to use

Sorry I can't post picture of log -- Here is gulpfile code

var gulp        = require('gulp');
var uglify      = require('gulp-uglify'); 

gulp.task('scripts', function () {
    gulp.src('assets/js/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('build/assets/js'));
});

gulp.task('styles', function () {

    gulp.src('assets/css/*.css')
    .pipe(uglify())
    .pipe(gulp.dest('build/assets/css'));
});

gulp.task('default', ['scripts', 'styles']
    gulp.src('assets/js/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('build/assets/js'));
like image 305
Mike Avatar asked Jun 04 '26 15:06

Mike


2 Answers

gulp.task('default', ['scripts', 'styles'], function(){
    gulp.src('assets/js/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('build/assets/js'));
});

add function(){ /*logic*/ }); you missed this in default

like image 60
joyBlanks Avatar answered Jun 07 '26 22:06

joyBlanks


Thanks - Yes, I missed function() - now gulp gives a ReferenceError: uglyfly is not defined. Here is code again

var gulp        = require('gulp'),
    uglify      = require('gulp-uglify'); 
gulp.task('scripts', function() {
  gulp.src('assets/js/*.js')
    .pipe(uglyfly())
    .pipe(gulp.dest('build/assets/js'))
});
gulp.task('styles', function() {
  gulp.src('assets/css/*.css')
    .pipe(uglyfly())
    .pipe(gulp.dest('build/assets/css'))
});

gulp.task('default', ['scripts', 'styles'], function () {

});
like image 35
Mike Avatar answered Jun 07 '26 23:06

Mike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!