var gulp = require("gulp");
var postcss = require("gulp-postcss");
var autoprefixer = require("autoprefixer");
var sass = require("gulp-sass");
var concat = require("gulp-concat");
var uglify = require("gulp-uglify");

gulp.task("sass", function() {
    return gulp.src("assets/sass/website.scss")
               .pipe(sass().on('error', sass.logError))
               .pipe(postcss([autoprefixer()]))
               .pipe(gulp.dest("uitwww/static"));
});

gulp.task("js", function() {
    return gulp.src(["assets/js/vendor/*.js",
                     "node_modules/vanilla-framework/js/core.js",
                     "assets/js/*.js"])
               .pipe(concat("website.js"))
               .pipe(uglify())
               .pipe(gulp.dest("uitwww/static"));
});

gulp.task("watch", function() {
    gulp.start("sass");
    gulp.start("js");
    gulp.watch("assets/sass/**/*.scss", ["sass"]);
    gulp.watch("assets/js/**/*.js", ["js"]);
});

gulp.task("default", function() {
    gulp.start("sass");
    gulp.start("js");
});
