]> git.ipfire.org Git - thirdparty/foundation/foundation-emails.git/commitdiff
Changed gulpfile to compile sass on any changed sass file. Also created a task to...
authorJeanie Chung <jeanie.chung@gmail.com>
Sat, 28 Feb 2015 03:48:48 +0000 (19:48 -0800)
committerJeanie Chung <jeanie.chung@gmail.com>
Sat, 28 Feb 2015 03:48:48 +0000 (19:48 -0800)
gulpfile.js

index 9fd5570d2a6ba340fdd78dda29204f5b95902cb0..5967cd3c6e8ced1fd8ce254feb64a2f6667e8eb2 100644 (file)
@@ -9,8 +9,7 @@
 //   4. Stylesheets
 //   5. HTML
 //   6. Testing
-//   7. GO FORTH AND BUILD
-//   8. Serve/Watch Tasks
+//   7. Utility Tasks
 
 // 1. LIBRARIES
 // - - - - - - - - - - - - - - -
@@ -28,21 +27,17 @@ var gulp       = require('gulp'),
     inkyGulp   = require('gulp-inky'),
     Handlebars = require('handlebars'),
     globLobLaw = require('glob'),
-
     // CSS stuff
     extractMQ  = require('media-query-extractor'),
     inject     = require('gulp-inject'),
     sass       = require('gulp-ruby-sass'),
     inlineCss  = require('gulp-inline-css');
 
-
-
-
 // 2. VARIABLES
 // - - - - - - - - - - - - - - -
 
 var dirs = {
-  styles: 'scss/*.scss',
+  styles: './scss',
   dist: './dist',
   spec: './spec',
   src: './src',
@@ -58,8 +53,8 @@ gulp.task('clean:dist', function(cb) {
 });
 
 // Clean temp directory
-gulp.task('clean:temp', function(cb) {
-  rimraf(dirs.temp, cb);
+gulp.task('clean:inline', function(cb) {
+  rimraf(dirs.dist + '/inline', cb);
 });
 
 
@@ -68,20 +63,20 @@ gulp.task('clean:temp', function(cb) {
 
 // Compile SASS files
 gulp.task('sass', function() {
-  return gulp.src(dirs.styles)
+  return gulp.src(dirs.styles + '/**/*.scss')
     .pipe(sass({ "sourcemap=none": true, style: 'compact' }))
     .pipe(gulp.dest(dirs.dist + '/css'))
     .pipe(connect.reload())
 });
 
 // Inline Styles
-gulp.task('inline', function() {
+gulp.task('inline', ['clean:inline'], function() {
   return gulp.src(dirs.dist + '/*.html')
     .pipe(inlineCss())
     .pipe(rename({
       suffix: '-inline'
     }))
-    .pipe(gulp.dest(dirs.dist))
+    .pipe(gulp.dest(dirs.dist + '/inline'))
 });
 
 // extract media queries into new CSS file called inkMQ.css
@@ -92,7 +87,7 @@ gulp.task('extract-mq', function () {
 
 // inject media queries into the head of the inlined email
 gulp.task('inject-mq', ['extract-mq'], function() {
-  gulp.src(dirs.dist + '/*.html')
+  gulp.src(dirs.dist + '/inline/*.html')
     .pipe(inject(gulp.src(dirs.dist + '/css/inkMQ.css'), {
       starttag: '<!-- inject:mq-css -->',
       transform: function (filePath, file) {
@@ -100,11 +95,9 @@ gulp.task('inject-mq', ['extract-mq'], function() {
         return "<style>\n" + file.contents.toString('utf8') + "\n</style>"
       }
     }))
-    .pipe(gulp.dest('./dist'));
+    .pipe(gulp.dest(dirs.dist + '/inline'));
 })
 
-
-
 // 5. HTML
 // - - - - - - - - - - - - - - -
 
@@ -120,14 +113,6 @@ gulp.task('minify-html', function() {
     .pipe(connect.reload())
 });
 
-// Task to copy HTML directly, without minifying
-gulp.task('copy-html', function() {
-  return gulp.src(dirs.src + '/layouts/*.html')
-  .pipe(gulp.dest(dirs.dist))
-  .pipe(connect.reload())
-});
-
-
 // Helper function to compile Handlebars partials
 
 var htmlParse = function(settings) {
@@ -178,18 +163,10 @@ gulp.task('inky-parse', function() {
 
 // });
 
-// 7. GO FORTH AND BUILD
-// - - - - - - - - - - - - - - -
-
-
-// Wipes build folder, then compiles SASS, then minifies and copies HTML
-gulp.task('build', function() {
-  runOrder('clean:dist', 'sass', 'inky-parse', 'minify-html');
-});
-
-// 8. Serve/Watch/Default Tasks
+// 7. Utility Tasks
 // - - - - - - - - - - - - - - -
 
+// Serve
 // Starts a server
 // Default Port: 8080
 gulp.task('serve', function() {
@@ -199,15 +176,26 @@ gulp.task('serve', function() {
   });
 });
 
+// Watch
 // Start a server
 // Watch all HTML files and SCSS files for changes
 // Live reloads on change
 gulp.task('watch', ['serve'], function() {
   gulp.watch([dirs.src + '/*/*.*'], ['inky-parse']);
-  gulp.watch([dirs.styles], ['sass']);
+  gulp.watch([dirs.styles + '/**/*.scss'], ['sass']);
+
+});
 
+// Build
+// Builds initial template folders
+// Should only have to run once
+gulp.task('build', ['clean:dist', 'sass'], function() {
+  gulp.start('inky-parse');
 });
 
+
+// Deploy
+// When you're all ready to send your email
 // Minify the html, inline the css, inject media queries in the head
 gulp.task('deploy', ['minify-html', 'inline'], function() {
   gulp.start('inject-mq');