Last active
April 4, 2016 12:28
-
-
Save craigmdennis/4d90cff0584b3dffec28127bed1aa393 to your computer and use it in GitHub Desktop.
Gulp Starter config file for using with Middleman as an external pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"root": { | |
"src": "./source", | |
"dest": "./.tmp" | |
}, | |
"tasks": { | |
"browserSync": { | |
"proxy": "http://localhost:4567", | |
"reloadDelay" : 2000 | |
}, | |
"static": { | |
"src": "static", | |
"dest": "./" | |
}, | |
"js": { | |
"src": "javascripts", | |
"dest": "javascripts", | |
"entries": { | |
"all": ["./all.js"] | |
}, | |
"extensions": ["js", "json"], | |
"babel": { | |
"presets": ["es2015", "stage-1"], | |
"plugins": [] | |
}, | |
"extractSharedJs": false | |
}, | |
"css": { | |
"src": "stylesheets", | |
"dest": "stylesheets", | |
"autoprefixer": { | |
"browsers": ["last 3 version"] | |
}, | |
"sass": { | |
"indentedSyntax": false, | |
"includePaths": [] | |
}, | |
"extensions": ["sass", "scss", "css"] | |
}, | |
"html": { | |
"src": "./", | |
"dest": "./", | |
"dataFile": "data/global.json", | |
"htmlmin": {}, | |
"extensions": ["html", "json", "erb", "haml"], | |
"excludeFolders": ["images", "javascripts", "stylesheets"] | |
}, | |
"images": { | |
"src": "images", | |
"dest": "images", | |
"extensions": ["jpg", "png", "svg", "gif"] | |
}, | |
"fonts": { | |
"src": "fonts", | |
"dest": "fonts", | |
"extensions": ["woff2", "woff", "eot", "ttf", "svg"] | |
}, | |
"iconFont": { | |
"src": "icons", | |
"dest": "fonts", | |
"sassDest": "generated", | |
"extensions": ["woff2", "woff", "eot", "ttf", "svg"] | |
}, | |
"svgSprite": { | |
"src": "icons", | |
"dest": "images", | |
"extensions": ["svg"] | |
}, | |
"production" : { | |
"rev": false | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = require('../config') | |
if(!config.tasks.html) return | |
var browserSync = require('browser-sync') | |
var data = require('gulp-data') | |
var gulp = require('gulp') | |
var gulpif = require('gulp-if') | |
var handleErrors = require('../lib/handleErrors') | |
var htmlmin = require('gulp-htmlmin') | |
var path = require('path') | |
var render = require('gulp-nunjucks-render') | |
var fs = require('fs') | |
var exclude = path.normalize('!**/{' + config.tasks.html.excludeFolders.join(',') + '}/**') | |
var paths = { | |
src: [path.join(config.root.src, config.tasks.html.src, '/**/*.{' + config.tasks.html.extensions + '}'), exclude], | |
dest: path.join(config.root.dest, config.tasks.html.dest), | |
} | |
var getData = function(file) { | |
var dataPath = path.resolve(config.root.src, config.tasks.html.src, config.tasks.html.dataFile) | |
return JSON.parse(fs.readFileSync(dataPath, 'utf8')) | |
} | |
var htmlTask = function() { | |
return gulp.src(paths.src) | |
// .pipe(data(getData)) | |
// .on('error', handleErrors) | |
// .pipe(render({ | |
// path: [path.join(config.root.src, config.tasks.html.src)], | |
// envOptions: { | |
// watch: false | |
// } | |
// })) | |
// .on('error', handleErrors) | |
// .pipe(gulpif(global.production, htmlmin(config.tasks.html.htmlmin))) | |
// .pipe(gulp.dest(paths.dest)) | |
.pipe(browserSync.stream()) | |
} | |
gulp.task('html', htmlTask) | |
module.exports = htmlTask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment