Change to gulpfile.js
This commit is contained in:
parent
bfeb0a69e6
commit
011bc69d9f
|
@ -1,3 +0,0 @@
|
|||
gulp = require 'gulp'
|
||||
|
||||
gulp.task 'build', ['clean', 'styles', 'scripts', 'fonts', 'images']
|
|
@ -1,6 +0,0 @@
|
|||
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}'
|
|
@ -1,3 +0,0 @@
|
|||
gulp = require 'gulp'
|
||||
|
||||
gulp.task 'default', ['build', 'watch']
|
|
@ -1,5 +0,0 @@
|
|||
gulp = require 'gulp'
|
||||
|
||||
gulp.task 'fonts', ->
|
||||
gulp.src gulp.config.bowerDir + '/font-awesome/fonts/*'
|
||||
.pipe gulp.dest gulp.config.outputDir + '/fonts'
|
|
@ -1,11 +0,0 @@
|
|||
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'
|
|
@ -1,6 +0,0 @@
|
|||
gulp = require 'gulp'
|
||||
|
||||
gulp.task 'minify-images', ->
|
||||
gulp.src gulp.config.assetsDir + '/images/**/*'
|
||||
.pipe gulp.plugins.imagemin()
|
||||
.pipe gulp.dest gulp.config.assetsDir + '/images'
|
|
@ -1,6 +0,0 @@
|
|||
gulp = require 'gulp'
|
||||
|
||||
gulp.task 'minify-prod-html', ->
|
||||
gulp.src 'output_prod/**/*.html'
|
||||
.pipe gulp.plugins.htmlmin 'collapseWhitespace': true
|
||||
.pipe gulp.dest 'output_prod'
|
|
@ -1,8 +0,0 @@
|
|||
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'
|
|
@ -1,7 +0,0 @@
|
|||
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'
|
|
@ -1,8 +0,0 @@
|
|||
gulp = require 'gulp'
|
||||
|
||||
gulp.task 'watch', ->
|
||||
gulp.plugins.refresh.listen()
|
||||
|
||||
gulp.watch gulp.config.sassPattern, ['styles']
|
||||
gulp.watch gulp.config.assetsDir + gulp.config.jsPattern, ['scripts']
|
||||
gulp.watch gulp.config.assetsDir + '/images/**/*', ['copy-images']
|
|
@ -1,39 +0,0 @@
|
|||
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 || false
|
||||
|
||||
gulp.css = (paths, filename) ->
|
||||
gulp.src paths
|
||||
.pipe gulp.plugins.plumber()
|
||||
.pipe gulp.plugins.if !gulp.config.production, 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.plugins.if gulp.config.production, gulp.plugins.cleanCss()
|
||||
.pipe gulp.plugins.if !gulp.config.production, gulp.plugins.sourcemaps.write '.'
|
||||
.pipe gulp.plugins.if !gulp.config.production, gulp.dest 'output_dev/assets/css'
|
||||
.pipe gulp.plugins.if !gulp.config.production, gulp.plugins.refresh()
|
||||
.pipe gulp.dest gulp.config.outputDir + '/css'
|
||||
|
||||
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.plugins.if gulp.config.production, gulp.plugins.uglify()
|
||||
.pipe gulp.plugins.if !gulp.config.production, gulp.plugins.sourcemaps.write '.'
|
||||
.pipe gulp.dest gulp.config.outputDir + '/js'
|
||||
|
||||
gulp.copy = (srcFiles, outputDir) ->
|
||||
gulp.src srcFiles
|
||||
.pipe gulp.dest outputDir
|
||||
|
||||
require("fs").readdirSync("./gulp").forEach (task) -> require "./gulp/#{task}"
|
103
gulpfile.js
Normal file
103
gulpfile.js
Normal file
|
@ -0,0 +1,103 @@
|
|||
'use strict';
|
||||
|
||||
var gulp = require('gulp'),
|
||||
plugins = require('gulp-load-plugins')(),
|
||||
del = require('del');
|
||||
|
||||
var config = {
|
||||
assetsDir: 'assets',
|
||||
bowerDir: 'vendor/bower',
|
||||
outputDir: 'source/assets',
|
||||
production: plugins.util.env.production || false
|
||||
};
|
||||
|
||||
var app = {};
|
||||
|
||||
app.css = function (paths, filename) {
|
||||
gulp.src(paths)
|
||||
.pipe(plugins.plumber())
|
||||
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
||||
.pipe(plugins.sassGlob())
|
||||
.pipe(plugins.sass())
|
||||
.pipe(plugins.autoprefixer({ browsers: 'last 2 versions' }))
|
||||
.pipe(plugins.concat(filename))
|
||||
.pipe(plugins.if(config.production, plugins.cleanCss()))
|
||||
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
|
||||
.pipe(plugins.if(!config.production, gulp.dest(config.outputDir + '/css')))
|
||||
.pipe(plugins.if(!config.production, plugins.refresh()))
|
||||
.pipe(gulp.dest(config.outputDir + '/css'));
|
||||
};
|
||||
|
||||
app.js = function (paths, filename) {
|
||||
gulp.src(paths)
|
||||
.pipe(plugins.plumber())
|
||||
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
||||
.pipe(plugins.concat(filename))
|
||||
.pipe(plugins.if(config.production, plugins.uglify()))
|
||||
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
|
||||
.pipe(gulp.dest(config.outputDir + '/js'));
|
||||
};
|
||||
|
||||
app.copy = function (source, destination) {
|
||||
gulp.src(source)
|
||||
.pipe(gulp.dest(destination));
|
||||
};
|
||||
|
||||
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('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.assetsDir + '/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('clean', function () {
|
||||
del.sync(config.outputDir + '/css');
|
||||
del.sync(config.outputDir + '/js');
|
||||
del.sync('output_*/assets/css');
|
||||
del.sync('output_*/assets/js');
|
||||
});
|
||||
|
||||
gulp.task('build', ['clean', 'styles', 'scripts', 'fonts', 'images']);
|
||||
|
||||
gulp.task('watch', function () {
|
||||
plugins.refresh.listen();
|
||||
|
||||
gulp.watch('assets/sass/**/*.sass', ['styles']);
|
||||
gulp.watch('assets/js/**/*.js', ['scripts']);
|
||||
gulp.watch('assets/images/**/*', ['copy-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'));
|
||||
});
|
Reference in a new issue