const gulp = require('gulp');
const less = require('gulp-less');
const sourcemaps = require('gulp-sourcemaps');

// Paths
const paths = {
  styles: {
    src: 'less/**/*.less',
    dest: 'styles/'
  }
};

// Compile LESS to CSS
function styles() {
  return gulp.src('less/wasteland.less')
    .pipe(sourcemaps.init())
    .pipe(less())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(paths.styles.dest));
}

// Watch files
function watchFiles() {
  gulp.watch(paths.styles.src, styles);
}

// Define complex tasks
const build = gulp.series(styles);
const watch = gulp.series(build, watchFiles);

// Export tasks
exports.styles = styles;
exports.build = build;
exports.watch = watch;
exports.default = build;
