2015-06-18 19:35:50 +02:00
|
|
|
var gulp = require("gulp");
|
2016-02-21 16:42:35 +02:00
|
|
|
var runseq = require('run-sequence');
|
2015-06-18 19:35:50 +02:00
|
|
|
var clean = require("gulp-clean");
|
|
|
|
var scss = require("gulp-sass");
|
|
|
|
var plumber = require("gulp-plumber");
|
|
|
|
var autoprefixer = require('gulp-autoprefixer');
|
|
|
|
var watch = require("gulp-watch");
|
2016-02-21 16:42:35 +02:00
|
|
|
var cssmin = require("gulp-cssmin");
|
2016-02-21 18:01:27 +02:00
|
|
|
var rimraf = require("rimraf");
|
2015-06-18 19:35:50 +02:00
|
|
|
|
|
|
|
var paths = {};
|
2016-02-21 16:42:35 +02:00
|
|
|
paths.app = "./resources/";
|
|
|
|
paths.output = "./resources/public/";
|
|
|
|
paths.dist = "./dist";
|
2015-06-18 19:35:50 +02:00
|
|
|
paths.scss = paths.app + "styles/**/*.scss";
|
|
|
|
|
2016-02-21 16:42:35 +02:00
|
|
|
gulp.task("scss", function() {
|
2015-06-18 19:35:50 +02:00
|
|
|
return gulp.src(paths.app + "styles/main.scss")
|
2016-02-21 16:42:35 +02:00
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(scss({ style: "expanded" }))
|
|
|
|
.pipe(gulp.dest(paths.output + "css/"));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("autoprefixer", function() {
|
|
|
|
return gulp.src(paths.output + "css/main.css")
|
|
|
|
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
|
|
|
|
.pipe(gulp.dest(paths.output + "css/"));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("cssmin", function() {
|
|
|
|
return gulp.src(paths.output + "css/main.css")
|
|
|
|
.pipe(cssmin())
|
|
|
|
.pipe(gulp.dest(paths.output + "css/"));
|
2015-06-18 19:35:50 +02:00
|
|
|
});
|
|
|
|
|
2016-02-21 16:42:35 +02:00
|
|
|
gulp.task("styles:dev", function(next) {
|
|
|
|
runseq("scss", "autoprefixer", next);
|
2015-06-18 19:35:50 +02:00
|
|
|
});
|
|
|
|
|
2016-02-21 16:42:35 +02:00
|
|
|
gulp.task("styles:dist", function(next) {
|
|
|
|
runseq("scss", "autoprefixer", next);
|
|
|
|
});
|
|
|
|
|
2016-02-21 18:01:27 +02:00
|
|
|
gulp.task("clean", function(next) {
|
|
|
|
rimraf(paths.output + "css/", function() {
|
|
|
|
rimraf(paths.output + "js/", next)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-02-21 16:42:35 +02:00
|
|
|
gulp.task("copy", function() {
|
|
|
|
return gulp.src(paths.output + "/**/*.*")
|
|
|
|
.pipe(gulp.dest(paths.dist));
|
|
|
|
});
|
2015-06-18 19:35:50 +02:00
|
|
|
|
|
|
|
// Default
|
2016-02-21 16:42:35 +02:00
|
|
|
gulp.task("dist", function(next) {
|
2016-02-21 18:01:27 +02:00
|
|
|
runseq("clean", "styles:dist", "cssmin", "copy", next);
|
2016-02-21 16:42:35 +02:00
|
|
|
});
|
2015-06-18 19:35:50 +02:00
|
|
|
|
|
|
|
// Watch
|
2016-02-21 16:42:35 +02:00
|
|
|
gulp.task("default", ["styles:dev"], function () {
|
2015-06-18 19:35:50 +02:00
|
|
|
gulp.watch(paths.scss, ["autoprefixer"]);
|
|
|
|
});
|