Creating a config.json for the gulpfile

This commit is contained in:
Jeff Avallone 2014-11-23 17:26:05 -05:00
parent 9fc138d87d
commit 3c5c1579e2
2 changed files with 33 additions and 21 deletions

21
config.json Normal file
View File

@ -0,0 +1,21 @@
{
"templateFile": "./template.html",
"globs": {
"other": "./src/**/*.!(html|scss|js)",
"html": "./src/**/*.html",
"sass": "./src/**/*.scss",
"js": "./src/**/*.js"
},
"compass": {
"sass": "./src/sass",
"css": "./build/css",
"javascript": "./build/js",
"font": "./build/font",
"sourcemap": true
},
"browserify": {
"entries": ["./main.js"],
"basedir": "./src/js",
"debug": true
}
}

View File

@ -1,10 +1,11 @@
var gulp = require('gulp'); var gulp = require('gulp'),
config = require('./config');
gulp.task('default', ['server'], function() { gulp.task('default', ['server'], function() {
gulp.watch('./src/**/*.!(html|scss|js)', ['static']); gulp.watch(config.globs.other, ['static']);
gulp.watch(['./src/**/*.html', './template.html'], ['markup']); gulp.watch([config.globs.html, config.templateFile], ['markup']);
gulp.watch('./src/**/*.scss', ['compass']); gulp.watch(config.globs.sass, ['compass']);
gulp.watch('./src/**/*.js', ['browserify']); gulp.watch(config.globs.js, ['browserify']);
}); });
gulp.task('server', ['build'], function() { gulp.task('server', ['build'], function() {
@ -22,40 +23,30 @@ gulp.task('server', ['build'], function() {
gulp.task('build', ['static', 'markup', 'compass', 'browserify']); gulp.task('build', ['static', 'markup', 'compass', 'browserify']);
gulp.task('static', function() { gulp.task('static', function() {
return gulp.src('./src/**/*.!(html|scss|js)') return gulp.src(config.globs.other)
.pipe(gulp.dest('./build')); .pipe(gulp.dest('./build'));
}); });
gulp.task('markup', function() { gulp.task('markup', function() {
var wrap = require('gulp-wrap'); var wrap = require('gulp-wrap');
return gulp.src('./src/**/*.html') return gulp.src(config.globs.html)
.pipe(wrap({ src: './template.html' })) .pipe(wrap({ src: config.templateFile }))
.pipe(gulp.dest('./build')); .pipe(gulp.dest('./build'));
}); });
gulp.task('compass', function() { gulp.task('compass', function() {
var compass = require('gulp-compass'); var compass = require('gulp-compass');
return gulp.src('./src/**/*.scss') return gulp.src(config.globs.sass)
.pipe(compass({ .pipe(compass(config.compass));
sass: './src/sass',
css: './build/css',
javascript: './build/js',
font: './build/font',
sourcemap: true
}));
}); });
gulp.task('browserify', function() { gulp.task('browserify', function() {
var browserify = require('browserify'), var browserify = require('browserify'),
es6ify = require('es6ify'), es6ify = require('es6ify'),
source = require('vinyl-source-stream'); source = require('vinyl-source-stream');
bundler = browserify({ bundler = browserify(config.browserify);
entries: ['./main.js'],
basedir: './src/js',
debug: true,
});
bundler.add(es6ify.runtime); bundler.add(es6ify.runtime);
bundler.transform(es6ify); bundler.transform(es6ify);