Use coffee script for gulp
This commit is contained in:
parent
534d3b11f4
commit
f012d89d72
3
gulp/build.coffee
Normal file
3
gulp/build.coffee
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
|
||||||
|
gulp.task 'build', ['clean', 'styles', 'scripts', 'fonts', 'images']
|
6
gulp/clean.coffee
Normal file
6
gulp/clean.coffee
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
del = require 'del'
|
||||||
|
|
||||||
|
gulp.task 'clean', ->
|
||||||
|
del.sync 'output_*/assets/{css,fonts,images,js}'
|
||||||
|
del.sync gulp.config.outputDir + '/{css,fonts,images,js}'
|
3
gulp/default.coffee
Normal file
3
gulp/default.coffee
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
|
||||||
|
gulp.task 'default', ['build', 'watch']
|
5
gulp/fonts.coffee
Normal file
5
gulp/fonts.coffee
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
|
||||||
|
gulp.task 'fonts', ->
|
||||||
|
gulp.src gulp.config.bowerDir + '/font-awesome/fonts/*'
|
||||||
|
.pipe gulp.dest gulp.config.outputDir + '/fonts'
|
11
gulp/images.coffee
Normal file
11
gulp/images.coffee
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
|
||||||
|
gulp.task 'images', -> gulp.start 'copy-images', 'meetup-thumbnails'
|
||||||
|
|
||||||
|
gulp.task 'meetup-thumbnails', ->
|
||||||
|
gulp.src gulp.config.assetsDir + '/images/meetups/originals/*'
|
||||||
|
.pipe gulp.plugins.imageResize height: '80'
|
||||||
|
.pipe gulp.dest gulp.config.outputDir + '/images/meetups/thumbnails'
|
||||||
|
|
||||||
|
gulp.task 'copy-images', ->
|
||||||
|
gulp.copy gulp.config.assetsDir + '/images/**/*', gulp.config.outputDir + '/images'
|
6
gulp/minify-prod-html.coffee
Normal file
6
gulp/minify-prod-html.coffee
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
|
||||||
|
gulp.task 'minify-prod-html', ->
|
||||||
|
gulp.src 'output_prod/**/*.html'
|
||||||
|
.pipe gulp.plugins.htmlmin 'collapseWhitespace': true
|
||||||
|
.pipe gulp.dest 'output_prod'
|
8
gulp/scripts.coffee
Normal file
8
gulp/scripts.coffee
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
|
||||||
|
gulp.task 'scripts', ->
|
||||||
|
gulp.js [
|
||||||
|
gulp.config.bowerDir + '/jquery/dist/jquery.js',
|
||||||
|
gulp.config.bowerDir + '/bootstrap-sass/assets/javascripts/bootstrap.js',
|
||||||
|
gulp.config.assetsDir + '/' + gulp.config.jsPattern
|
||||||
|
], 'site.js'
|
7
gulp/styles.coffee
Normal file
7
gulp/styles.coffee
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
|
||||||
|
gulp.task 'styles', ->
|
||||||
|
gulp.css [
|
||||||
|
gulp.config.bowerDir + '/font-awesome/css/font-awesome.css',
|
||||||
|
gulp.config.assetsDir + '/sass/site.sass'
|
||||||
|
], 'site.css'
|
5
gulp/watch.coffee
Normal file
5
gulp/watch.coffee
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
|
||||||
|
gulp.task 'watch', ->
|
||||||
|
gulp.watch gulp.config.sassPattern, ['styles']
|
||||||
|
gulp.watch gulp.config.assetsDir + gulp.config.jsPattern, ['scripts']
|
43
gulpfile.coffee
Normal file
43
gulpfile.coffee
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
gulp = require 'gulp'
|
||||||
|
gulp.plugins = require('gulp-load-plugins')()
|
||||||
|
|
||||||
|
gulp.config =
|
||||||
|
assetsDir: './assets',
|
||||||
|
bowerDir: './vendor/bower',
|
||||||
|
outputDir: './source/assets',
|
||||||
|
sassPattern: './assets/sass/**/*.sass',
|
||||||
|
jsPattern: 'js/**/*.js',
|
||||||
|
production: !!gulp.plugins.util.env.production,
|
||||||
|
sourceMaps: !gulp.plugins.util.env.production,
|
||||||
|
liveReload: !gulp.plugins.util.env.production,
|
||||||
|
notify: !gulp.plugins.util.env.production
|
||||||
|
|
||||||
|
gulp.css = (paths, filename) ->
|
||||||
|
gulp.src paths
|
||||||
|
.pipe gulp.plugins.plumber()
|
||||||
|
.pipe gulp.plugins.if gulp.config.sourceMaps, gulp.plugins.sourcemaps.init()
|
||||||
|
.pipe gulp.plugins.sassGlob()
|
||||||
|
.pipe gulp.plugins.sass()
|
||||||
|
.pipe gulp.plugins.autoprefixer browsers: ['last 2 versions']
|
||||||
|
.pipe gulp.plugins.concat filename
|
||||||
|
.pipe gulp.config.production ? gulp.plugins.cleanCss() || gulp.plugins.util.noop()
|
||||||
|
.pipe gulp.plugins.if gulp.config.sourceMaps, gulp.plugins.sourcemaps.write '.'
|
||||||
|
.pipe gulp.dest gulp.config.outputDir + '/css'
|
||||||
|
# .pipe gulp.config.notify ? gulp.plugins.notify() || gulp.plugins.util.noop()
|
||||||
|
# .pipe gulp.plugins.if gulp.config.liveReload, gulp.plugins.livereload()
|
||||||
|
|
||||||
|
gulp.js = (paths, filename) ->
|
||||||
|
gulp.src paths
|
||||||
|
.pipe gulp.plugins.plumber()
|
||||||
|
.pipe gulp.plugins.if gulp.config.sourceMaps, gulp.plugins.sourcemaps.init()
|
||||||
|
.pipe gulp.plugins.concat filename
|
||||||
|
.pipe gulp.config.production ? gulp.plugins.uglify() || gulp.plugins.util.noop()
|
||||||
|
.pipe gulp.plugins.if gulp.config.sourceMaps, gulp.plugins.sourcemaps.write '.'
|
||||||
|
.pipe gulp.dest gulp.config.outputDir + '/js'
|
||||||
|
# .pipe gulp.config.notify ? gulp.plugins.notify() || gulp.plugins.util.noop()
|
||||||
|
|
||||||
|
gulp.copy = (srcFiles, outputDir) ->
|
||||||
|
gulp.src srcFiles
|
||||||
|
.pipe gulp.dest outputDir
|
||||||
|
|
||||||
|
require("fs").readdirSync("./gulp").forEach (task) -> require "./gulp/#{task}"
|
109
gulpfile.js
109
gulpfile.js
|
@ -1,109 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var gulp = require('gulp');
|
|
||||||
var plugins = require('gulp-load-plugins')();
|
|
||||||
var del = require('del');
|
|
||||||
|
|
||||||
var config = {
|
|
||||||
assetsDir: './assets',
|
|
||||||
bowerDir: './vendor/bower',
|
|
||||||
outputDir: './source/assets',
|
|
||||||
sassPattern: './assets/sass/**/*.sass',
|
|
||||||
jsPattern: 'js/**/*.js',
|
|
||||||
production: !!plugins.util.env.production,
|
|
||||||
sourceMaps: !plugins.util.env.production,
|
|
||||||
liveReload: !plugins.util.env.production,
|
|
||||||
notify: !plugins.util.env.production
|
|
||||||
};
|
|
||||||
|
|
||||||
var app = {};
|
|
||||||
|
|
||||||
app.css = function (paths, filename) {
|
|
||||||
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.autoprefixer({
|
|
||||||
browsers: ['last 2 versions']
|
|
||||||
}))
|
|
||||||
.pipe(plugins.concat(filename))
|
|
||||||
.pipe(config.production ? plugins.cleanCss() : plugins.util.noop())
|
|
||||||
.pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.write('.')))
|
|
||||||
.pipe(gulp.dest(config.outputDir + '/css'))
|
|
||||||
.pipe(config.notify ? plugins.notify() : plugins.util.noop())
|
|
||||||
.pipe(plugins.if(config.liveReload, plugins.livereload()));
|
|
||||||
};
|
|
||||||
|
|
||||||
app.js = function (paths, filename) {
|
|
||||||
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('.')))
|
|
||||||
.pipe(gulp.dest(config.outputDir + '/js'))
|
|
||||||
.pipe(config.notify ? plugins.notify() : plugins.util.noop());
|
|
||||||
};
|
|
||||||
|
|
||||||
app.copy = function (srcFiles, outputDir) {
|
|
||||||
gulp.src(srcFiles)
|
|
||||||
.pipe(gulp.dest(outputDir));
|
|
||||||
};
|
|
||||||
|
|
||||||
gulp.task('styles', function () {
|
|
||||||
app.css([
|
|
||||||
config.bowerDir + '/font-awesome/css/font-awesome.css',
|
|
||||||
config.assetsDir + '/sass/site.sass'
|
|
||||||
], 'site.css');
|
|
||||||
});
|
|
||||||
|
|
||||||
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');
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('watch', function () {
|
|
||||||
gulp.watch(config.sassPattern, ['styles']);
|
|
||||||
gulp.watch(config.assetsDir + config.jsPattern, ['scripts']);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('clean', function () {
|
|
||||||
del.sync('output_*/assets/{css,fonts,images,js}');
|
|
||||||
del.sync(config.outputDir + '/{css,fonts,images,js}');
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('fonts', function () {
|
|
||||||
app.copy(config.bowerDir + '/font-awesome/fonts/*', config.outputDir + '/fonts');
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('meetup-thumbnails', function () {
|
|
||||||
gulp.src(config.assetsDir + '/images/meetups/originals/*')
|
|
||||||
.pipe(plugins.imageResize({
|
|
||||||
height: '80'
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest(config.outputDir + '/images/meetups/thumbnails'))
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('copy-images', function () {
|
|
||||||
app.copy(config.assetsDir + '/images/**/*', config.outputDir + '/images');
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('images', ['meetup-thumbnails', 'copy-images']);
|
|
||||||
|
|
||||||
gulp.task('build', ['clean', 'styles', 'scripts', 'fonts', 'images']);
|
|
||||||
|
|
||||||
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'));
|
|
||||||
});
|
|
Loading…
Reference in a new issue