0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 00:10:11 -05:00
penpot/gulpfile.js

86 lines
2.3 KiB
JavaScript
Raw Normal View History

2015-06-18 12:35:50 -05:00
var gulp = require("gulp");
2016-02-21 09:42:35 -05:00
var runseq = require('run-sequence');
2015-06-18 12:35:50 -05: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 09:42:35 -05:00
var cssmin = require("gulp-cssmin");
2016-02-21 11:01:27 -05:00
var rimraf = require("rimraf");
var mustache = require("gulp-mustache");
var rename = require("gulp-rename");
2015-06-18 12:35:50 -05:00
var paths = {};
2016-02-21 09:42:35 -05:00
paths.app = "./resources/";
paths.output = "./resources/public/";
2016-02-21 13:42:01 -05:00
paths.dist = "./dist/";
2016-02-21 13:50:26 -05:00
paths.target = "./target/";
2015-06-18 12:35:50 -05:00
paths.scss = paths.app + "styles/**/*.scss";
2016-02-21 09:42:35 -05:00
gulp.task("scss", function() {
2015-06-18 12:35:50 -05:00
return gulp.src(paths.app + "styles/main.scss")
2016-02-21 09:42:35 -05:00
.pipe(plumber())
2016-02-21 13:50:26 -05:00
.pipe(scss({style: "expanded"}))
2016-02-21 09:42:35 -05:00
.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 12:35:50 -05:00
});
gulp.task("template", function() {
var ts = Math.floor(new Date());
var tmpl = mustache({
jsfile: "/js/main.js?v=" + ts,
cssfile: "/css/main.css?v=" + ts
})
return gulp.src(paths.app + "index.mustache")
.pipe(tmpl)
.pipe(rename("index.html"))
.pipe(gulp.dest(paths.output));
});
2016-02-21 13:50:26 -05:00
gulp.task("styles-dev", function(next) {
2016-02-21 09:42:35 -05:00
runseq("scss", "autoprefixer", next);
2015-06-18 12:35:50 -05:00
});
2016-02-21 13:50:26 -05:00
gulp.task("styles-dist", function(next) {
2016-02-21 09:42:35 -05:00
runseq("scss", "autoprefixer", next);
});
2016-02-21 13:50:26 -05:00
gulp.task("clean-dist", function(next) {
rimraf(paths.dist, next);
2016-02-21 13:42:01 -05:00
});
2016-02-21 13:50:26 -05:00
gulp.task("clean", function(next) {
2016-02-21 11:01:27 -05:00
rimraf(paths.output + "css/", function() {
2016-02-21 13:50:26 -05:00
rimraf(paths.output + "js/", function() {
rimraf(paths.target, next);
});
2016-02-21 11:01:27 -05:00
});
});
2016-02-21 09:42:35 -05:00
gulp.task("copy", function() {
return gulp.src(paths.output + "/**/*.*")
.pipe(gulp.dest(paths.dist));
});
2015-06-18 12:35:50 -05:00
// Default
2016-02-21 09:42:35 -05:00
gulp.task("dist", function(next) {
runseq("styles-dist", "cssmin", "template", "clean-dist", "copy", next);
2016-02-21 09:42:35 -05:00
});
2015-06-18 12:35:50 -05:00
// Watch
gulp.task("default", ["styles-dev", "template"], function () {
2016-02-24 09:45:28 -05:00
gulp.watch(paths.scss, ["styles-dev"]);
2015-06-18 12:35:50 -05:00
});