// 4. Stylesheets
// 5. HTML
// 6. Testing
-// 7. GO FORTH AND BUILD
-// 8. Serve/Watch Tasks
+// 7. Utility Tasks
// 1. LIBRARIES
// - - - - - - - - - - - - - - -
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',
});
// Clean temp directory
-gulp.task('clean:temp', function(cb) {
- rimraf(dirs.temp, cb);
+gulp.task('clean:inline', function(cb) {
+ rimraf(dirs.dist + '/inline', 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
// 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) {
return "<style>\n" + file.contents.toString('utf8') + "\n</style>"
}
}))
- .pipe(gulp.dest('./dist'));
+ .pipe(gulp.dest(dirs.dist + '/inline'));
})
-
-
// 5. HTML
// - - - - - - - - - - - - - - -
.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) {
// });
-// 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() {
});
});
+// 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');