Skip to content

Instantly share code, notes, and snippets.

@dniccum dniccum/slang-gulpfile.js Secret
Last active Mar 14, 2017

Embed
What would you like to do?
AEM slang asset compilation
/**
* Var Declarations
*/
var gulp,
sass,
cache,
notify,
notifier,
argv,
runSequence,
srcFolder,
targetFolder,
cssTargetFolder,
cssBaseFolder,
cssLocalTargetFolder,
jsTargetFolder,
jsBaseFolder,
templateBaseFolder,
verboseOutput,
slang;
gulp = require('gulp');
cache = require('gulp-cached');
sass = require('gulp-sass');
notify = require('gulp-notify');
notifier = require('node-notifier');
runSequence = require('run-sequence');
argv = require('yargs').argv;
slang = require('gulp-slang');
srcFolder = '../../';
targetFolder = '/Volumes/localhost/etc/clientlibs/bscorpcomm-sites/americas/';
templateBaseFolder = '../../../../../../apps/bscorpcomm-sites/americas/';
verboseOutput = false;
if (argv.path) {
targetFolder = argv.path;
}
if (argv.verbose) {
verboseOutput = true;
}
cssTargetFolder = targetFolder + 'global/css/';
cssBaseFolder = srcFolder + '/dev/scss/';
cssLocalTargetFolder = srcFolder + 'global/css/';
jsTargetFolder = targetFolder + 'footer/js/';
jsBaseFolder = srcFolder + '/footer/js/';
/**
* Compile Tasks
*/
gulp.task('sass', function(){
return gulp.src([
cssBaseFolder + 'style.scss'
])
.pipe(sass({errLogToConsole: true}))
.on('error', onError)
.pipe(gulp.dest(cssLocalTargetFolder));
});
function onError(err) {
console.log(err);
this.emit('end');
}
/**
* Copy Tasks
*/
gulp.task('copy-css', function() {
return gulp.src([
cssLocalTargetFolder + 'style.css'
],{ dot: true })
.pipe(slang([
cssLocalTargetFolder + 'style.css'
], {
port: 4502
}));
});
/**
* Watch Tasks
*/
gulp.task('watch', function() {
gulp.watch(jsBaseFolder + '**/*.js', function(e) {
var path = e.path;
console.log('gulp watch JS triggered: ' + path);
return gulp.src(path)
.pipe(slang(path, {
port: 4502
}));
});
gulp.watch(templateBaseFolder + '**/*.jsp', function(e) {
var path = e.path;
console.log('gulp watch Template/Component JSP triggered: ' + path);
return gulp.src(path)
.pipe(slang(path, {
port: 4502
}));
});
gulp.watch(templateBaseFolder + '**/*.html', function(e) {
var path = e.path;
console.log('gulp watch Template/Component Sightly HTML triggered: ' + path);
return gulp.src(path)
.pipe(slang(path, {
port: 4502
}));
});
gulp.watch(cssBaseFolder + '**/*.scss', ['compile-sass']);
});
/**
* Notify Tasks
*/
gulp.task('notify-sass-complete', function() {
notifier.notify({
title: 'SASS Complete',
message: 'All CSS was compiled',
});
});
/**
* Builds
*/
gulp.task('compile-sass', function(callback) {
runSequence(
'sass',
'copy-css',
callback);
});
gulp.task('default', ['watch']);
{
"name": "frontend-build",
"version": "0.0.0",
"description": "Gulp build for front enders to circumvent full Maven builds.",
"main": "gulpfile.js",
"scripts": {
"gulp": "gulp",
"watch": "gulp watch"
},
"author": "",
"license": "ISC",
"dependencies": {
"gulp": "3.9.0",
"gulp-cached": "1.0.4",
"gulp-notify": "2.2.0",
"gulp-sass": "2.1.0",
"node-notifier": "4.4.0",
"run-sequence": "1.0.2",
"yargs": "3.7.2"
},
"devDependencies": {
"gulp-slang": "0.3.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.