Skip to content

Instantly share code, notes, and snippets.

@vladzadvorny
Last active November 17, 2016 18:37
Show Gist options
  • Save vladzadvorny/c41440f7f95ad937d0195387a5ebdbe0 to your computer and use it in GitHub Desktop.
Save vladzadvorny/c41440f7f95ad937d0195387a5ebdbe0 to your computer and use it in GitHub Desktop.
/**
$ npm install -g bower
$ npm install --global gulp-cli
$ npm init && mkdir app\scss app\css app\js dist && copy nul .bowerrc && copy nul app\index.html && copy nul app\scss\main.scss && npm install --save-dev gulp browser-sync gulp-concat gulp-rename gulp-sass node-neat node-bourbon gulp-uglifyjs gulp-notify
.bowerrc
{
"directory" : "app/libs/"
}
$ bower init
@import "bourbon";
@import "neat";
*/
var gulp = require('gulp'),
browserSync = require('browser-sync').create(),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
neat = require('node-neat').includePaths,
concat = require('gulp-concat'),
uglify = require('gulp-uglifyjs'),
notify = require('gulp-notify');
// gulp.task('less', function() {
// return gulp.src('./app/less/main.less')
// .pipe(plumber())
// .pipe(less())
// .pipe(rename({ basename: "style" }))
// .pipe(gulp.dest('./app/css'))
// .pipe(browserSync.stream());
// });
gulp.task('sass', function() {
return gulp.src('app/scss/main.scss')
.pipe(sass({
includePaths: ['sass'].concat(neat)
}).on('error', notify.onError({
message: "<%= error.message %>",
title: "Sass Error!"
})))
.pipe(rename({ basename: "style" }))
.pipe(gulp.dest('./app/css'))
.pipe(browserSync.stream());
});
// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {
browserSync.init({
server: "./app",
notify: false
});
gulp.watch('app/scss/**/*.scss', ['sass']);
gulp.watch('app/js/*.js').on('change', browserSync.reload);
gulp.watch('app/*.html').on('change', browserSync.reload);
});
gulp.task('default', ['serve']);
//
gulp.task('js', function() {
return gulp.src([ // Берем все необходимые библиотеки
'./app/libs/jquery/dist/jquery.js',
'./app/libs/bootstrap/dist/js/bootstrap.js',
'./app/libs/parallax.js/parallax.js'
])
.pipe(concat('libs.js')) // Собираем их в кучу в новом файле libs.min.js
//.pipe(uglify()) // Сжимаем JS файл
.pipe(gulp.dest('./app/js')); // Выгружаем в папку app/js
});
gulp.task('css', function() {
return gulp.src([
'./app/libs/bootstrap/dist/css/bootstrap.css'
])
.pipe(concat('main.css')) // Собираем их в кучу в новом файле libs.min.js
//.pipe(uglify()) // Сжимаем JS файл
.pipe(gulp.dest('./app/css')); // Выгружаем в папку app/js
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment