Last active
September 10, 2015 19:33
-
-
Save Igloczek/f4676f7337ec41ec0413 to your computer and use it in GitHub Desktop.
Sample Gulp config
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
var gulp = require('gulp'); | |
var plumber = require('gulp-plumber'); | |
var print = require('gulp-print'); | |
var notify = require("gulp-notify"); | |
var sass = require('gulp-sass'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var csslint = require('gulp-csslint'); | |
var autoprefixer = require('gulp-autoprefixer'); | |
var uglify = require('gulp-uglify'); | |
var browserSync = require('browser-sync'); | |
var eslint = require('gulp-eslint'); | |
var reload = browserSync.reload; | |
var paths = { | |
template: '../app/design/frontend/snowdog/v2/**', | |
sass: '../skin/frontend/snowdog/v2/scss', | |
css: '../skin/frontend/snowdog/v2/css', | |
scripts: '../skin/frontend/snowdog/v2/js/dev', | |
custom: '../skin/frontend/snowdog/v2/js/dev/*.js', | |
libs: '../skin/frontend/snowdog/v2/js/dev/lib/*.js', | |
build: '../skin/frontend/snowdog/v2/js/build' | |
}; | |
var esLintSettings = { | |
configFile: './.eslintrc' | |
}; | |
var cssLintSettings = { | |
'adjoining-classes': false, | |
'box-model': false, | |
'box-sizing': false, | |
'compatible-vendor-prefixes': false, | |
'empty-rules': false, | |
'display-property-grouping': false, | |
'duplicate-background-images': false, | |
'duplicate-properties': false, | |
'fallback-colors': false, | |
'floats': false, | |
'font-faces': false, | |
'font-sizes': false, | |
'gradients': false, | |
'ids': false, | |
'import': false, | |
'important': false, | |
'known-properties': false, | |
'outline-none': false, | |
'overqualified-elements': false, | |
'qualified-headings': false, | |
'regex-selectors': false, | |
'shorthand': false, | |
'star-property-hack': false, | |
'text-indent': false, | |
'underscore-property-hack': false, | |
'unique-headings': false, | |
'universal-selector': false, | |
'unqualified-attributes': false, | |
'vendor-prefix': false, | |
'zero-units': false, | |
}; | |
gulp.task('default', ['dev', 'watch', 'scripts', 'libs']); | |
// browser sync | |
gulp.task('dev', function() { | |
browserSync({ | |
proxy: "eobuwie.dev" | |
}); | |
}); | |
// watch tasks | |
gulp.task('watch', function() { | |
gulp.watch(paths.sass + '/**', ['sass', 'galanteria']); | |
gulp.watch(paths.template, reload); | |
gulp.watch(paths.build + '/*.js', reload); | |
}); | |
// compile SASS | |
gulp.task('sass', function() { | |
return gulp.src(paths.sass + '/*.scss') | |
.pipe(plumber({ | |
errorHandler: notify.onError("Error: <%= error.message %>") | |
})) | |
// .pipe(sourcemaps.init()) | |
.pipe(sass({ | |
outputStyle: 'compressed' | |
})) | |
.pipe(autoprefixer()) | |
.pipe(csslint(cssLintSettings)) | |
.pipe(csslint.reporter()) | |
// .pipe(sourcemaps.write()) | |
.pipe(gulp.dest(paths.css)) | |
.pipe(reload({ | |
stream: true | |
})); | |
}); | |
gulp.task('galanteria', function() { | |
return gulp.src('../skin/frontend/snowdog/v2-galanteria/scss/*.scss') | |
.pipe(plumber({ | |
errorHandler: notify.onError("Error: <%= error.message %>") | |
})) | |
// .pipe(sourcemaps.init()) | |
.pipe(sass({ | |
outputStyle: 'compressed' | |
})) | |
.pipe(autoprefixer()) | |
.pipe(csslint(cssLintSettings)) | |
.pipe(csslint.reporter()) | |
// .pipe(sourcemaps.write()) | |
.pipe(gulp.dest('../skin/frontend/snowdog/v2-galanteria/css')) | |
.pipe(reload({ | |
stream: true | |
})); | |
}); | |
// lint and build custom scripts on changes | |
gulp.task('scripts', function() { | |
gulp.watch(paths.custom, function(event) { | |
gulp.src(event.path) | |
.pipe(plumber({ | |
errorHandler: notify.onError("ESLint found problems") | |
})) | |
.pipe(print(event.path)) | |
.pipe(eslint(esLintSettings)) | |
.pipe(eslint.format()) | |
// .pipe(eslint.failOnError()) | |
.pipe(uglify()) | |
.pipe(gulp.dest(paths.build)); | |
}); | |
}); | |
// lint and build libs on changes | |
gulp.task('libs', function() { | |
gulp.watch(paths.libs, function(event) { | |
gulp.src(event.path) | |
.pipe(plumber({ | |
errorHandler: notify.onError("Error: <%= error.message %>") | |
})) | |
.pipe(print(event.path)) | |
.pipe(uglify()) | |
.pipe(gulp.dest(paths.build + '/lib')); | |
}); | |
}); | |
// lint all custom scripts | |
gulp.task('js-lint', function() { | |
return gulp.src(paths.custom) | |
.pipe(print(this.path)) | |
.pipe(plumber({ | |
errorHandler: notify.onError("ESLint found problems") | |
})) | |
.pipe(eslint(esLintSettings)) | |
.pipe(eslint.format()); | |
}); | |
// lint all css files | |
gulp.task('css-lint', function() { | |
return gulp.src(paths.css + '/*.css') | |
.pipe(print(this.path)) | |
.pipe(plumber({ | |
errorHandler: notify.onError("Error: <%= error.message %>") | |
})) | |
.pipe(csslint()) | |
.pipe(csslint.reporter()); | |
}); | |
// build all JS | |
gulp.task('build-all-js', function() { | |
return gulp.src(paths.scripts + '/**/*.js') | |
.pipe(print(this.path)) | |
.pipe(uglify()) | |
.pipe(gulp.dest(paths.build)) | |
}); | |
// bulid release | |
gulp.task('release', ['sass', 'galanteria', 'build-all-js']); |
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
{ | |
"devDependencies": { | |
"browser-sync": "^2.9.3", | |
"gulp": "^3.9.0", | |
"gulp-autoprefixer": "^3.0.1", | |
"gulp-csslint": "^0.1.5", | |
"gulp-eslint": "^1.0.0", | |
"gulp-notify": "^2.2.0", | |
"gulp-plumber": "^1.0.1", | |
"gulp-print": "^1.1.0", | |
"gulp-sass": "^2.0.4", | |
"gulp-sourcemaps": "^1.5.2", | |
"gulp-uglify": "^1.4.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment