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

// Compile LESS to CSS
function styles() {
  return gulp.src('less/malefices.less')
    .pipe(sourcemaps.init())
    .pipe(less())
    .pipe(rename('simple.css'))
    .pipe(sourcemaps.write('.', { mapFile: () => 'simple.css.map' }))
    .pipe(gulp.dest('styles/'));
}

// Watch files
function watchFiles() {
  gulp.watch('less/**/*.less', styles);
}

const build = gulp.series(styles);
const watch = gulp.series(build, watchFiles);

exports.styles = styles;
exports.build = build;
exports.watch = watch;
exports.default = build;
