-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"directory" : "app/libs/" | ||
"directory" : "assets/libs/" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
assets/libs | ||
*.log | ||
*.psd |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,84 @@ | ||
var gulp = require('gulp'); | ||
sass = require('gulp-sass'); //Подключаем Sass пакет | ||
browserSync = require('browser-sync'); // Подключаем Browser Sync | ||
concat = require('gulp-concat'), // Подключаем gulp-concat (для конкатенации файлов) | ||
uglify = require('gulp-uglifyjs'); // Подключаем gulp-uglifyjs (для сжатия JS) | ||
cssnano = require('gulp-cssnano'), // Подключаем пакет для минификации CSS | ||
rename = require('gulp-rename'); // Подключаем библиотеку для переименования файлов | ||
del = require('del'); // Подключаем библиотеку для удаления файлов и папок | ||
imagemin = require('gulp-imagemin'), // Подключаем библиотеку для работы с изображениями | ||
pngquant = require('imagemin-pngquant'); // Подключаем библиотеку для работы с png | ||
cache = require('gulp-cache'); // Подключаем библиотеку кеширования | ||
autoprefixer = require('gulp-autoprefixer');// Подключаем библиотеку для автоматического добавления | ||
|
||
|
||
|
||
|
||
|
||
gulp.task('mytask', function () { | ||
return gulp.src('source-files') // Выборка исходных файлов для обработки плагином | ||
.pipe(plugin()) // Вызов Gulp плагина для обработки файла | ||
.pipe(gulp.dest('folder')) // Вывод результирующего файла в папку назначения (dest - пункт назначения) | ||
}) | ||
|
||
gulp.task('sass', function(){ | ||
return gulp.src('assets/scss/**/*.scss') // Берем все sass файлы из папки sass и дочерних, если таковые будут | ||
.pipe(sass()) | ||
.pipe(gulp.dest('assets/css')) | ||
}); | ||
|
||
gulp.task('browser-sync', function() { // Создаем таск browser-sync | ||
browserSync({ // Выполняем browser Sync | ||
server: { // Определяем параметры сервера | ||
baseDir: 'app' // Директория для сервера - app | ||
sass = require('gulp-sass'); | ||
browserSync = require('browser-sync'); | ||
concat = require('gulp-concat'), | ||
uglify = require('gulp-uglifyjs'); | ||
cssnano = require('gulp-cssnano'), | ||
rename = require('gulp-rename'); | ||
del = require('del'); | ||
imagemin = require('gulp-imagemin'), | ||
pngquant = require('imagemin-pngquant'); | ||
cache = require('gulp-cache'); | ||
autoprefixer = require('gulp-autoprefixer'); | ||
|
||
|
||
gulp.task('browser-sync', function() { | ||
browserSync({ | ||
server: { | ||
baseDir: 'assets' | ||
}, | ||
notify: false // Отключаем уведомления | ||
notify: false | ||
}); | ||
}); | ||
|
||
|
||
gulp.task('scripts', function() { | ||
return gulp.src([ // Берем все необходимые библиотеки | ||
'app/libs/jquery/dist/jquery.min.js', // Берем jQuery | ||
'app/libs/magnific-popup/dist/jquery.magnific-popup.min.js' // Берем Magnific Popup | ||
]) | ||
.pipe(concat('libs.min.js')) // Собираем их в кучу в новом файле libs.min.js | ||
.pipe(uglify()) // Сжимаем JS файл | ||
.pipe(gulp.dest('assets/js')); // Выгружаем в папку app/js | ||
return gulp.src([]); | ||
.pipe(concat('')) | ||
.pipe(uglify()) | ||
.pipe(gulp.dest('assets/js')); | ||
}); | ||
|
||
gulp.task('watch', ['browser-sync', 'css-min', 'scripts'], function() { | ||
gulp.task('watch', ['browser-sync', 'sass', 'scripts'], function() { | ||
gulp.watch('assets/scss/**/*.scss', ['sass']); | ||
gulp.watch('assets/*.html', browserSync.reload); | ||
gulp.watch('assets/js/**/*.js', browserSync.reload); | ||
}); | ||
|
||
gulp.task('css-libs', ['sass'], function() { | ||
return gulp.src('app/css/libs.css') // Выбираем файл для минификации | ||
.pipe(cssnano()) // Сжимаем | ||
.pipe(rename({suffix: '.min'})) // Добавляем суффикс .min | ||
.pipe(gulp.dest('assets/css')); // Выгружаем в папку app/css | ||
}); | ||
|
||
gulp.task('img', function() { | ||
return gulp.src('assets/img/**/*') // Берем все изображения из app | ||
.pipe(imagemin({ // Сжимаем их с наилучшими настройками | ||
return gulp.src('assets/img/*.+(png|jpg|svg)') | ||
.pipe(imagemin({ | ||
interlaced: true, | ||
progressive: true, | ||
svgoPlugins: [{removeViewBox: false}], | ||
use: [pngquant()] | ||
})) | ||
.pipe(gulp.dest('assets/img')); // Выгружаем на продакшен | ||
.pipe(gulp.dest('assets/img')); | ||
}); | ||
|
||
|
||
gulp.task('sass', function(){ // Создаем таск Sass | ||
return gulp.src('assets/sass/**/*.sass') // Берем источник | ||
.pipe(sass()) // Преобразуем Sass в CSS посредством gulp-sass | ||
.pipe(autoprefixer(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true })) // Создаем префиксы | ||
.pipe(gulp.dest('assets/css')) // Выгружаем результата в папку app/css | ||
.pipe(browserSync.reload({stream: true})) // Обновляем CSS на странице при изменении | ||
gulp.task('sass', function() { | ||
return gulp.src('assets/sass/**/*.sass') | ||
.pipe(sass()) | ||
.pipe(autoprefixer(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true })) | ||
.pipe(gulp.dest('assets/css')) | ||
.pipe(browserSync.reload({stream: true})); | ||
}); | ||
|
||
|
||
gulp.tast('clean', function() { | ||
return del.sync(['css', 'fonts', 'img', 'js', 'index.html']); | ||
}); | ||
|
||
gulp.task('build', ['clean', 'img', 'sass', 'scripts'], function() { | ||
|
||
var buildCss = gulp.src('assets/css/*.css') | ||
.pipe(gulp.dest('css')) | ||
|
||
var buildFonts = gulp.src('assets/fonts/**/*') | ||
|
||
var buildJs = gulp.src('assets/js/**/*.js') | ||
.pipe(gulp.dest('js')) | ||
|
||
var buildHtml = gulp.src('assets/index.html') | ||
.pipe(gulp.dest('')); | ||
|
||
}); | ||
|
||
|
||
gulp.task('clear', function () { | ||
return cache.clearAll(); | ||
}) | ||
}); | ||
|
||
gulp.task('default', ['watch']); |