Browse Source

Move out most of the Gulpfile to preset dependencies

master
Sven Slootweg 6 years ago
parent
commit
e19279db73
  1. 81
      gulpfile.js
  2. 4
      package.json

81
gulpfile.js

@ -4,17 +4,15 @@ var path = require("path");
var xtend = require("xtend");
var rfr = require("rfr");
var riot = require("gulp-riot");
var sass = require("gulp-sass");
var jade = require("gulp-jade");
var babel = require("gulp-babel");
var livereload = require("gulp-livereload");
var cache = require("gulp-cached");
var remember = require("gulp-remember");
var plumber = require("gulp-plumber");
var rename = require("gulp-rename");
var namedLog = require("gulp-named-log");
var presetES2015 = require("@joepie91/gulp-preset-es2015");
var presetJade = require("@joepie91/gulp-preset-jade");
var presetSCSS = require("@joepie91/gulp-preset-scss");
var presetRiot = require("@joepie91/gulp-preset-riot");
var runProcess = rfr("src/gulp/run-process");
var patchLivereloadLogger = rfr("src/gulp/patch-livereload-logger");
@ -22,10 +20,6 @@ var loggerOptions = {
basePath: __dirname
}
var babelLogger = namedLog("babel", loggerOptions);
var jadeLogger = namedLog("jade", loggerOptions);
var sassLogger = namedLog("sass", loggerOptions);
var riotLogger = namedLog("riot", loggerOptions);
var electronLogger = namedLog("electron", loggerOptions);
var livereloadLogger = namedLog("livereload", loggerOptions);
@ -39,14 +33,6 @@ var sources = {
"riot-components": "src/components/**/*.tag"
}
function getLiveReloadStream() {
var lr = livereload({
quiet: true
});
return lr;
}
gulp.task("electron", ['babel-lib', 'babel-main', 'jade-views', 'sass-main', 'riot-components'], function() {
var electronProcess = runProcess(path.join(__dirname, "node_modules/.bin/electron"), [__dirname], {
logger: electronLogger,
@ -58,67 +44,56 @@ gulp.task("electron", ['babel-lib', 'babel-main', 'jade-views', 'sass-main', 'ri
gulp.task('babel-main', function() {
return gulp.src(sources["babel-main"])
.pipe(plumber(babelLogger.error))
.pipe(cache("babel-main"))
.pipe(babel({presets: ["es2015"]}))
.pipe(babelLogger.stream())
.pipe(getLiveReloadStream())
.pipe(presetES2015({
livereload: livereload,
basePath: __dirname
}))
.pipe(rename("app.es5.js"))
.pipe(gulp.dest("./"));
});
gulp.task('babel-lib', function() {
return gulp.src(sources["babel-lib"])
.pipe(plumber(babelLogger.error))
.pipe(cache("babel-lib"))
.pipe(babel({presets: ["es2015"]}))
.pipe(babelLogger.stream())
.pipe(getLiveReloadStream())
.pipe(gulp.dest("lib/"));
.pipe(presetES2015({
livereload: livereload,
basePath: __dirname
}))
.pipe(gulp.dest("./lib/"));
});
gulp.task("jade-views", function() {
return gulp.src(sources["jade-views"])
.pipe(plumber(jadeLogger.error))
.pipe(cache("jade-views"))
.pipe(jade())
.pipe(jadeLogger.stream())
.pipe(getLiveReloadStream())
.pipe(presetJade({
livereload: livereload,
basePath: __dirname
}))
.pipe(gulp.dest("lib/views/"));
});
gulp.task("sass-main", function() {
return gulp.src(sources["sass-main"])
.pipe(plumber(sassLogger.error))
.pipe(cache("sass-main"))
.pipe(sass())
.pipe(sassLogger.stream())
.pipe(getLiveReloadStream())
.pipe(presetSCSS({
livereload: livereload,
basePath: __dirname
}))
.pipe(gulp.dest("lib/stylesheets/"));
});
gulp.task("riot-components", function() {
return gulp.src(sources["riot-components"])
.pipe(plumber(riotLogger.error))
.pipe(cache("riot-components"))
.pipe(riot({
type: "babel",
template: "jade",
style: "scss"
.pipe(presetRiot({
livereload: livereload,
basePath: __dirname
}))
.pipe(riotLogger.stream())
.pipe(getLiveReloadStream())
.pipe(gulp.dest("lib/components/"));
});
gulp.task('watch', function () {
livereload.listen();
gulp.watch(sources["babel-lib"], ["babel-lib"]);
gulp.watch(sources["babel-main"], ["babel-main"]);
gulp.watch(sources["jade-views"], ["jade-views"]);
gulp.watch(sources["sass-main"], ["sass-main"]);
gulp.watch(sources["riot-components"], ["riot-components"]);
Object.keys(sources).forEach(function(source) {
gulp.watch(sources[source], [source]);
});
});
gulp.task('default', ['watch', 'electron']);

4
package.json

@ -37,6 +37,10 @@
"xtend": "^4.0.1"
},
"devDependencies": {
"@joepie91/gulp-preset-es2015": "^1.0.0",
"@joepie91/gulp-preset-jade": "^1.0.0",
"@joepie91/gulp-preset-riot": "^1.0.0",
"@joepie91/gulp-preset-scss": "^1.0.0",
"babel-core": "^6.7.6",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015-riot": "^1.0.4",

Loading…
Cancel
Save