Created
March 7, 2015 12:19
-
-
Save falendary/208d48fbc5bf61061e0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Инициализируем плагины | |
var gulp = require('gulp'), // Сообственно Gulp JS | |
stylus = require('gulp-stylus'), // Sass | |
jade = require('gulp-jade'), // Jade | |
coffee = require('gulp-coffee'); // coffee-script | |
csso = require('gulp-csso'), // Минификация CSS | |
uglify = require('gulp-uglify'), // Минификация JS | |
concat = require('gulp-concat'), // Склейка файлов | |
connect = require('gulp-connect'); // http-сервер | |
// Создает дерево проекта | |
gulp.task('gen', function(){ | |
}); | |
// Собираем Stylus | |
gulp.task('stylus', function () { | |
gulp.src('./app/assets/stylus/**/*.styl') | |
.pipe(stylus()) // Преобразуем в css | |
.on('error', console.log) // Если есть ошибки, выводим и продолжаем | |
.pipe(concat('style.css')) // склеиваем полученные css в style.css | |
.pipe(gulp.dest('./app/public/css')) // отправляем в версию для разработки | |
.pipe(connect.reload()); | |
}); | |
// Собираем Jade | |
gulp.task('jade', function() { | |
gulp.src(['./app/assets/jade/**/*.jade', '!./app/assets/jade/utils/*.jade']) | |
.pipe(jade({ | |
pretty: true | |
})) // Собираем Jade только в папке assets/template/ исключая файлы из utils | |
.on('error', console.log) // Если есть ошибки, выводим и продолжаем | |
.pipe(gulp.dest('./app/public/')) // отправляем в версию для разработки | |
.pipe(connect.reload()); // даем команду на перезагрузку страницы | |
}); | |
// Собираем JS | |
gulp.task('js', function() { | |
gulp.src(['./app/assets/coffee/**/*.coffee']) | |
.pipe(coffee({bare: true})) | |
.on('error', console.log) | |
//.pipe(concat('script.js')) // Склеиваем JS | |
.pipe(gulp.dest('./app/public/js')) | |
.pipe(connect.reload()); // даем команду на перезагрузку страницы | |
}); | |
// Локальный сервер для разработки | |
gulp.task('http-server', function() { | |
connect.server( | |
{ | |
root: 'app/public', | |
livereload: true | |
}); | |
}); | |
// Смотрим за изменениями | |
gulp.task('watch', function () { | |
gulp.watch(['./app/assets/stylus/**/*.styl'], ['sass']); | |
gulp.watch(['./app/assets/jade/**/*.jade'], ['jade']); | |
gulp.watch(['./app/assets/coffee/**/*.coffee'], ['js']); | |
}); | |
// Запуск сервера разработки gulp watch | |
gulp.task('default', ['http-server', 'watch']); | |
// Запуск сборщика продакшена | |
gulp.task('build', function() { | |
// sass | |
gulp.src('./app/assets/stylus/**/*.styl') | |
.pipe(sass()) // преобразуем sass в css | |
.pipe(concat('style.css')) // склеиванием css | |
// .pipe(csso()) // минимизируем css | |
.pipe(gulp.dest('./app/build/css/')) // записываем css | |
// jade | |
gulp.src(['./app/assets/jade/**/*.jade', '!./app/assets/jade/utils/**/*.jade']) | |
.pipe(jade({ | |
pretty: true | |
})) | |
.pipe(gulp.dest('./app/build/')) | |
// js | |
gulp.src(['./app/assets/coffee/**/*.coffee', './app/assets/coffee/**/*.js']) | |
.pipe(coffee({bare: true})) | |
// .pipe(uglify()) | |
.pipe(gulp.dest('./app/build/js')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment