Skip to content

Commit

Permalink
Pull in updated build script, and move theme back into root.
Browse files Browse the repository at this point in the history
  • Loading branch information
Besim Huskic committed Jan 26, 2015
2 parents 910afe0 + 987abb2 commit 2e2f4a4
Show file tree
Hide file tree
Showing 85 changed files with 631 additions and 2,678 deletions.
122 changes: 87 additions & 35 deletions _gulp/config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
var dest = './assets',
src = './_src';
// Paths
var assetsDir = './assets',
sourceDir = './_src',
appDir = './';

var paths = {
images: src + '/images/**/*',
scripts: src + '/js/**/*.js',
sprites: src + '/sprites/*.png',
styles: src + '/sass/**/*.{sass,scss}'
};
// Source Directory
var _source = {
root: sourceDir,
images: sourceDir + '/images/**/*',
scripts: sourceDir + '/js/',
sprites: sourceDir + '/sprites/*.png',
styles: sourceDir + '/sass/**/*.{sass,scss}',
symbols: sourceDir + '/symbols/*.svg',
tpl: sourceDir + '/tpl/'
};

// Assets Directory
var _assets = {
root: assetsDir,
images: assetsDir + '/images/',
scripts: assetsDir + '/js/',
sprites: assetsDir + '/images/sprites/',
styles: assetsDir + '/css/',
symbols: assetsDir + '/fonts/symbols/'
}

// What sort of pre-processor are we utilizing?
var _processor = {
format: 'scss'
};

// Gulp options/settings for tasks.
module.exports = {
browserify: {
debug: true,
bundleConfigs: [{
entries: _source.scripts + 'main.js',
dest: _assets.scripts,
outputName: 'main.js'
}]
},
sass: {
src: paths.styles,
// For non Wordpress installs, change dest to
// dest: dest + '/css',
dest: './',
src: _source.styles,
dest: appDir,
settings: {
"sourcemap=none": true,
style: 'nested',
Expand All @@ -22,36 +50,60 @@ module.exports = {
trace: true
}
},
sprite: {
src: paths.sprites,
dest_img: dest + '/images/sprites',
dest_sass: src + '/sass/helpers',
autoprefixer: {
browsers: [
'last 2 versions',
'safari 5',
'ie 8',
'ie 9',
'android 4'
],
cascade: true
},
sprites: {
src: _source.sprites,
destSprites: _assets.sprites,
destSass: _source.root + '/sass/helpers',
settings: {
name: 'sprite.png',
retina: true,
style: '_sprites.scss',
cssPath: '../images/sprites',
processor: 'scss',
style: '_sprites.' + _processor.format,
cssPath: _assets.sprites,
processor: _processor.format,
orientation: 'binary-tree',
prefix: 'sprite'
}
},
symbols: {
src: _source.symbols,
tplCss: _source.tpl + 'symbols.tpl.css',
tplSass: _source.tpl + 'symbols.tpl.' + _processor.format,
tplHtml: _source.tpl + 'symbols.tpl.html',
destFont: _assets.symbols,
destSass: _source.root + '/sass/helpers',
settings: {
fontName: 'Symbols',
appendCodepoints: false,
centerHorizontally: true,
normalize: true,
fontHeight: false
},
renameSass: {
basename: '_symbols',
extname: '.' + _processor.format
}
},
images: {
src: paths.images,
dest: dest + '/images'
src: _source.images,
dest: _assets.images
},
browserify: {
// A separate bundle will be generated for each
// bundle config in the list below
bundleConfigs: [{
entries: paths.scripts,
dest: dest + '/js',
outputName: 'main.js',
require: ['jquery']
}]
watch: {
src: _source.root,
dest: _assets.root,
},
production: {
cssSrc: dest + '/*.css',
jsSrc: dest + '/*.js',
dest: dest
cssSrc: appDir + '*.css',
cssDest: appDir,
jsSrc: _assets.scripts + '*.js',
jsDest: _assets.scripts
}
};
};
85 changes: 85 additions & 0 deletions _gulp/tasks/browserify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* browserify task
---------------
Bundle javascripty things with browserify!
This task is set up to generate multiple separate bundles, from
different sources, and to use Watchify when run from the default task.
See browserify.bundleConfigs in gulp/config.js
*/

var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
var bundleLogger = require('../util/bundleLogger');
var handleErrors = require('../util/handleErrors');
var config = require('../config').browserify;


var browserifyTask = function(callback, devMode) {

var bundleQueue = config.bundleConfigs.length;

var browserifyThis = function(bundleConfig) {

var bundler = browserify({
// Required watchify args
cache: {}, packageCache: {}, fullPaths: false,
// Specify the entry point of your app
entries: bundleConfig.entries,
// Add file extentions to make optional in your requires
extensions: config.extensions,
// Enable source maps!
debug: config.debug
});

var bundle = function() {
// Log when bundling starts
bundleLogger.start(bundleConfig.outputName);

return bundler
.bundle()
// Report compile errors
.on('error', handleErrors)
// Use vinyl-source-stream to make the
// stream gulp compatible. Specifiy the
// desired output filename here.
.pipe(source(bundleConfig.outputName))
// Specify the output destination
.pipe(gulp.dest(bundleConfig.dest))
.on('end', reportFinished);
};

if(global.isWatching) {
// Wrap with watchify and rebundle on changes
bundler = watchify(bundler);
// Rebundle on update
bundler.on('update', bundle);
}

var reportFinished = function() {
// Log when bundling completes
bundleLogger.end(bundleConfig.outputName)

if(bundleQueue) {
bundleQueue--;
if(bundleQueue === 0) {
// If queue is empty, tell gulp the task is complete.
// https://github.com/gulpjs/gulp/blob/master/docs/API.md#accept-a-callback
callback();
}
}
};

return bundle();
};

// Start bundling with Browserify for each bundleConfig specified
config.bundleConfigs.forEach(browserifyThis);
};

gulp.task('browserify', browserifyTask);

// Exporting the task so we can call it directly in our watch task, with the 'devMode' option
module.exports = browserifyTask
2 changes: 1 addition & 1 deletion _gulp/tasks/default.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var gulp = require('gulp');

gulp.task('default', ['sass', 'images', 'sprites', 'watch']);
gulp.task('default', ['symbols', 'sass', 'images', 'sprites', 'watch']);
14 changes: 7 additions & 7 deletions _gulp/tasks/images.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var changed = require('gulp-changed'),
gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
config = require('../config').images,
livereload = require('gulp-livereload');
var changed = require('gulp-changed'),
gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
config = require('../config').images,
livereload = require('gulp-livereload');

gulp.task('images', function() {
return gulp.src(config.src)
.pipe(changed(config.dest)) // Ignore unchanged files
.pipe(imagemin()) // Optimize
.pipe(changed(config.dest))
.pipe(imagemin())
.pipe(gulp.dest(config.dest))
.pipe(livereload());
});
8 changes: 5 additions & 3 deletions _gulp/tasks/minifyCss.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
var gulp = require('gulp'),
config = require('../config').production,
minifyCSS = require('gulp-minify-css'),
size = require('gulp-filesize');
size = require('gulp-filesize'),
combineMQ = require('gulp-combine-mq');

gulp.task('minifyCss', ['sass'], function() {
return gulp.src(config.cssSrc)
.pipe(minifyCSS({keepBreaks:true}))
.pipe(gulp.dest(config.dest))
.pipe(combineMQ())
.pipe(minifyCSS({advanced:false}))
.pipe(gulp.dest(config.cssDest))
.pipe(size());
})
2 changes: 1 addition & 1 deletion _gulp/tasks/production.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var gulp = require('gulp');

// Run this to compress all the things!
gulp.task('production', ['images', 'minifyCss', 'uglifyJs']);
gulp.task('production', ['minifyCss', 'uglifyJs']);
15 changes: 9 additions & 6 deletions _gulp/tasks/sass.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
var gulp = require('gulp'),
livereload = require('gulp-livereload'),
sass = require('gulp-ruby-sass'),
sourcemaps = require('gulp-sourcemaps'),
gulpFilter = require('gulp-filter'),
handleErrors = require('../util/handleErrors'),
config = require('../config').sass,
autoprefixer = require('gulp-autoprefixer');
config = require('../config'),
autoprefixer = require('gulp-autoprefixer'),
livereload = require('gulp-livereload');

gulp.task('sass', function () {
return gulp.src(config.src)
return gulp.src(config.sass.src)
.pipe(sourcemaps.init())
.pipe(sass(config.settings))
.pipe(sass(config.sass.settings))
.on('error', handleErrors)
.pipe(sourcemaps.write())
.pipe(autoprefixer({ browsers: ['last 2 version'] }))
.pipe(gulp.dest(config.dest))
.pipe(gulp.dest(config.sass.dest))
.pipe(livereload());
});

//.pipe(autoprefixer(config.autoprefixer))
15 changes: 9 additions & 6 deletions _gulp/tasks/sprites.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
var gulp = require('gulp'),
config = require('../config').sprite,
sprite = require('css-sprite').stream,
gulpif = require('gulp-if');
var gulp = require('gulp'),
config = require('../config').sprites,
sprite = require('css-sprite').stream,
gulpif = require('gulp-if'),
livereload = require('gulp-livereload');

gulp.task('sprites', function() {
return gulp.src(config.src)
.pipe(sprite(config.settings))
.pipe(gulpif('*.png', gulp.dest(config.dest_img)))
.pipe(gulpif('*.scss', gulp.dest(config.dest_sass)));
.pipe(gulpif('*.png', gulp.dest(config.destSprites)))
.pipe(gulpif('*.sass', gulp.dest(config.destSass)))
.pipe(gulpif('*.scss', gulp.dest(config.destSass)))
.pipe(livereload());
});
44 changes: 44 additions & 0 deletions _gulp/tasks/symbols.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var gulp = require('gulp'),
config = require('../config').symbols,
iconfont = require('gulp-iconfont'),
consolidate = require('gulp-consolidate'),
rename = require('gulp-rename'),
livereload = require('gulp-livereload');

gulp.task('symbols', function () {
return gulp.src(config.src)
.pipe(iconfont(config.settings))
.on('codepoints', function(codepoints, options) {
// Options for when the scss/sass files are being generated.
var optionsSass = {
glyphs: codepoints,
fontName: 'symbols',
fontPath: 'assets/fonts/symbols/',
className: 'symbol'
};
// Options for when the preview files are being generated.
var optionsHtml = {
glyphs: codepoints,
fontName: 'symbols',
fontPath: '',
className: 'symbol'
};
// Generate sass/scss file for symbols
gulp.src(config.tplSass)
.pipe(consolidate('lodash', optionsSass))
.pipe(rename(config.renameSass))
.pipe(gulp.dest(config.destSass));
// Generate HTML file for symbol preview
gulp.src(config.tplHtml)
.pipe(consolidate('lodash', optionsHtml))
.pipe(rename({ basename:'symbols' }))
.pipe(gulp.dest(config.destFont));
// Generate css file for HTML preview
gulp.src(config.tplCss)
.pipe(consolidate('lodash', optionsHtml))
.pipe(rename({ basename:'symbols' }))
.pipe(gulp.dest(config.destFont));
})
.pipe(gulp.dest(config.destFont))
.pipe(livereload());
});
10 changes: 5 additions & 5 deletions _gulp/tasks/uglifyJs.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var gulp = require('gulp'),
config = require('../config').production,
size = require('gulp-filesize'),
uglify = require('gulp-uglify');
var gulp = require('gulp'),
config = require('../config').production,
size = require('gulp-filesize'),
uglify = require('gulp-uglify');

gulp.task('uglifyJs', ['browserify'], function() {
return gulp.src(config.jsSrc)
.pipe(uglify())
.pipe(gulp.dest(config.dest))
.pipe(gulp.dest(config.jsDest))
.pipe(size());
});
Loading

0 comments on commit 2e2f4a4

Please sign in to comment.