user45038
user45038

Reputation: 57

Gulp was working but then stopped

I am stuck, I have been trying to learn gulp and I am slowly putting together a gulpfile.

I got to a point testing as I went along and everything was fine. A few days later I returned to continue with it and now it doesn't work. I have no clue whats wrong.

my gulp file

var gulp = require('gulp'),

// required for CSS and LESS
less = require('gulp-less');
prefix = require('gulp-autoprefixer'),
minifyCSS = require('gulp-minify-css');

// required for JS
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),

rename = require("gulp-rename");

var paths = {
  src : {
    less       : '.assets/less/styles.less',
    js_main    : '.assets/scripts/main.js',
    js_plugins : '.assets/scripts/plugins/*.js',
    img        : ''
  },
  dest : {
    css : './public/assets/css/',
    js  : './public/assets/js/',
    img : ''
  }
};

gulp.task('styles', function() {
  gulp.src( paths.src.less )
  .pipe( less() )
  .pipe( prefix("last 2 version", "> 1%", "ie 8", "ie 7") )
  .pipe( gulp.dest( paths.dest.css ) )
  .pipe( rename('styles.min.js') )
  .pipe( minifyCSS() )
  .pipe( gulp.dest( paths.dest.css ) );
 });

gulp.task('scripts', function() {
  gulp.src( paths.src.js_main )
  .pipe( concat('main.js') )
  .pipe( gulp.dest( paths.dest.js ) )
  .pipe( rename('main.min.js') )
  .pipe( uglify() )
  .pipe( gulp.dest( paths.dest.js ) );
});

gulp.task('plugins', function() {
  gulp.src( paths.src.js_plugins )
  .pipe( concat('plugins.js') )
  .pipe( gulp.dest( paths.dest.js ) )
  .pipe( rename('plugins.min.js') )
  .pipe( uglify() )
  .pipe( gulp.dest( paths.dest.js ) );
});

So this was working when I stopped working on it but when I ran gulp styles in terminal days later i get this:

$ gulp styles
[gulp] Using gulpfile ~/projects/boilerplates/website-boilerplate/gulpfile.js
[gulp] Starting 'styles'...
[gulp] Finished 'styles' after 3.8 ms

so far I have tried to delete the installed node modules and re install them. I have also tried installing gulp globally again.

Would appreciate any help or suggestions.

Upvotes: 2

Views: 2214

Answers (1)

OverZealous
OverZealous

Reputation: 39570

It looks like gulp is running to me. What do you mean it isn't working?

One thing that's wrong with your gulpfile is you need to return the streams, like this:

gulp.task('styles', function() {
  return gulp.src( paths.src.less )
//^^^^^^

Otherwise gulp won't know when a particular task is finished. This (or another async option) needs to be done for every task.

Upvotes: 1

Related Questions