2016-03-29 21:44:47 +00:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var plugins = require('gulp-load-plugins')();
|
|
|
|
var del = require('del');
|
|
|
|
|
|
|
|
var config = {
|
|
|
|
assetsDir: './assets',
|
2016-03-30 12:56:01 +00:00
|
|
|
bowerDir: './vendor/bower',
|
|
|
|
outputDir: './source/assets',
|
2016-03-29 21:44:47 +00:00
|
|
|
sassPattern: './assets/sass/**/*.sass',
|
2016-03-30 12:56:01 +00:00
|
|
|
jsPattern: 'js/**/*.js',
|
2016-03-29 21:44:47 +00:00
|
|
|
production: !!plugins.util.env.production,
|
|
|
|
sourceMaps: !plugins.util.env.production,
|
|
|
|
liveReload: !plugins.util.env.production
|
|
|
|
};
|
|
|
|
|
|
|
|
var app = {};
|
|
|
|
|
|
|
|
app.css = function (paths, filename) {
|
2016-03-29 22:49:18 +00:00
|
|
|
gulp.src(paths)
|
|
|
|
.pipe(plugins.plumber())
|
|
|
|
.pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.init()))
|
|
|
|
.pipe(plugins.sourcemaps.init())
|
|
|
|
.pipe(plugins.sassGlob())
|
|
|
|
.pipe(plugins.sass())
|
|
|
|
.pipe(plugins.concat(filename))
|
|
|
|
.pipe(config.production ? plugins.cleanCss() : plugins.util.noop())
|
|
|
|
.pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.write('.')))
|
2016-03-30 12:56:01 +00:00
|
|
|
.pipe(gulp.dest(config.outputDir + '/css'))
|
2016-03-29 22:49:18 +00:00
|
|
|
.pipe(plugins.if(config.liveReload, plugins.livereload()));
|
2016-03-29 21:44:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
app.js = function (paths, filename) {
|
2016-03-29 22:49:18 +00:00
|
|
|
gulp.src(paths)
|
|
|
|
.pipe(plugins.plumber())
|
|
|
|
.pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.init()))
|
|
|
|
.pipe(plugins.sourcemaps.init())
|
|
|
|
.pipe(plugins.concat(filename))
|
|
|
|
.pipe(config.production ? plugins.uglify() : plugins.util.noop())
|
|
|
|
.pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.write('.')))
|
2016-03-30 12:56:01 +00:00
|
|
|
.pipe(gulp.dest(config.outputDir + '/js'));
|
2016-03-29 21:44:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
app.copy = function (srcFiles, outputDir) {
|
2016-03-29 22:49:18 +00:00
|
|
|
gulp.src(srcFiles)
|
|
|
|
.pipe(gulp.dest(outputDir));
|
2016-03-29 21:44:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
gulp.task('styles', function () {
|
2016-03-30 12:56:01 +00:00
|
|
|
app.css([
|
|
|
|
config.bowerDir + '/font-awesome/css/font-awesome.css',
|
|
|
|
config.assetsDir + '/sass/site.sass',
|
|
|
|
], 'site.css');
|
2016-03-29 21:44:47 +00:00
|
|
|
});
|
|
|
|
|
2016-03-30 12:56:01 +00:00
|
|
|
gulp.task('scripts', function () {
|
|
|
|
app.js([
|
|
|
|
config.bowerDir + '/jquery/dist/jquery.js',
|
|
|
|
config.bowerDir + '/bootstrap-sass/assets/javascripts/bootstrap.js',
|
|
|
|
config.assetsDir + config.jsPattern
|
|
|
|
], 'site.js');
|
|
|
|
})
|
|
|
|
|
2016-03-29 21:44:47 +00:00
|
|
|
gulp.task('watch', function () {
|
|
|
|
gulp.watch(config.sassPattern, ['styles']);
|
2016-03-30 12:56:01 +00:00
|
|
|
gulp.watch(config.assetsDir + config.jsPattern, ['scripts']);
|
2016-03-29 21:44:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('clean', function () {
|
2016-03-30 12:56:01 +00:00
|
|
|
del.sync('output_*/assets/{css,fonts,images,js}');
|
|
|
|
del.sync(config.outputDir + '/{css,fonts,images,js}');
|
2016-03-29 21:44:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('vendor-styles', function () {
|
|
|
|
app.css([
|
|
|
|
config.assetsDir + '/sass/vendor.sass',
|
|
|
|
'vendor/bower/font-awesome/css/font-awesome.css'
|
|
|
|
], 'vendor.css')
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('vendor-scripts', function () {
|
|
|
|
app.js([
|
|
|
|
'vendor/bower/jquery/dist/jquery.js',
|
|
|
|
'vendor/bower/bootstrap-sass/assets/javascripts/bootstrap/collapse.js',
|
|
|
|
'scripts/vendor/**/*.js'
|
|
|
|
], 'vendor.js');
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('vendor', ['vendor-styles', 'vendor-scripts']);
|
|
|
|
|
|
|
|
gulp.task('fonts', function () {
|
2016-03-30 12:56:01 +00:00
|
|
|
app.copy(config.bowerDir + '/font-awesome/fonts/*', config.outputDir + '/fonts');
|
2016-03-29 21:44:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('meetup-thumbnails', function () {
|
|
|
|
gulp.src(config.assetsDir + '/images/meetups/originals/*')
|
|
|
|
.pipe(plugins.imageResize({
|
|
|
|
height: '50'
|
|
|
|
}))
|
2016-03-30 12:56:01 +00:00
|
|
|
.pipe(gulp.dest(config.outputDir + '/images/meetups/thumbnails'))
|
2016-03-29 21:44:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('copy-images', function () {
|
2016-03-30 12:56:01 +00:00
|
|
|
app.copy(config.assetsDir + '/images/**/*', config.outputDir + '/images');
|
2016-03-29 21:44:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('images', ['meetup-thumbnails', 'copy-images']);
|
|
|
|
|
2016-03-30 12:56:01 +00:00
|
|
|
gulp.task('build', ['clean', 'styles', 'scripts', 'fonts', 'images']);
|
2016-03-29 21:44:47 +00:00
|
|
|
|
|
|
|
gulp.task('default', ['build', 'watch']);
|
|
|
|
|
|
|
|
gulp.task('minify-prod-html', function () {
|
|
|
|
gulp.src('output_prod/**/*.html')
|
|
|
|
.pipe(plugins.htmlmin({
|
|
|
|
'collapseWhitespace': true
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('output_prod'));
|
|
|
|
});
|