Marc Andre Jiacarrini Marc Andre Jiacarrini - 3 months ago 16
Node.js Question

Output directory not set

I am a total newbie to

gulp.js
,
I started this project and I have an
index.jade
file in
source/jade
directory. Now I have to output
jade2html
files in build directory,
so I used this gulp file:

// Gulp.js configuration

// include gulp and plugins
var
gulp = require('gulp');



// file locations
var
source = 'source/',
dest = 'build/';


// Jader
var jade = require('gulp-jade');

gulp.task('jadehtml', function() {
var YOUR_LOCALS = {};

gulp.src('source/jade/')
.pipe(jade({
locals: YOUR_LOCALS
}))
.pipe(gulp.dest('build/'))
});


But somehow when I run
gulp command
it outputs a blank directory in build directory. the black directory is named jade.html
Please tell me how to fix.
Thanks.

Answer

Does this fix your problem? I just cleaned up your gulp file: grouped the requirements, removed the unused path variables, and removed the demo gulp-jade options.

var gulp = require('gulp'),
    jade = require('gulp-jade');

gulp.task('jadehtml', function() {
  return gulp.src(['source/jade/*.jade'])
    .pipe(jade())
    .pipe(gulp.dest('build'))
});

This assumes that all your jade files are in source/jade. As @kosbr said, you can use return gulp.src(['source/jade/**/*.jade']) if you need to include files that are in subfolders of source/jade.

Run this with gulp jadehtml. If you still have problems at least we'll have a clean place to start debugging from.