Last active
September 19, 2016 20:40
-
-
Save danny-englander/e6c69db85cdeabca750ffa304b4061ef to your computer and use it in GitHub Desktop.
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
// Include gulp | |
var gulp = require('gulp'); | |
// Include plugins | |
var jshint = require('gulp-jshint'), | |
plumber = require('gulp-plumber'), | |
sass = require('gulp-sass'), | |
spritesmith = require('gulp.spritesmith'), | |
uglify = require('gulp-uglify'), | |
concat = require('gulp-concat'), | |
cssmin = require('gulp-cssmin'), | |
rename = require('gulp-rename'), | |
newer = require('gulp-newer'), | |
imagemin = require('gulp-imagemin'), | |
lr = require('tiny-lr'), | |
server = lr(), | |
runSequence = require('run-sequence'), | |
stripCssComments = require('gulp-strip-css-comments'), | |
sourcemaps = require('gulp-sourcemaps'), | |
shell = require('gulp-shell'), | |
concatCss = require('gulp-concat-css'), | |
browserSync = require('browser-sync'); | |
// Minify JS | |
gulp.task('scripts', function () { | |
return gulp.src(['js/plugins.js', 'js-source/dolphinea.js']) | |
.pipe(concat('vendor/dolphinea.min.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('js')) | |
.pipe(browserSync.reload({stream: true})); | |
}); | |
// Lint JS | |
gulp.task('lint', function () { | |
return gulp.src('js/script.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')); | |
}); | |
// Compile Sass | |
gulp.task('sass', function () { | |
return gulp.src('css-source/**/*.scss') | |
.pipe(plumber({ | |
errorHandler: function (err) { | |
console.log(err); | |
this.emit('end'); | |
} | |
})) | |
.pipe(sourcemaps.init()) | |
.pipe(sass({outputStyle: 'expanded'})) | |
.pipe(sourcemaps.write('../maps', { | |
includeContent: false, | |
sourceRoot: '../css-source/*/**', | |
mapSources: 'gulp../css-source/*/**', | |
debug: true | |
})) | |
.pipe(gulp.dest('css')) | |
.pipe(browserSync.reload({stream: true})); | |
}); | |
// Sprites | |
gulp.task('sprite', function () { | |
var spriteData = gulp.src('images-source/*.png').pipe(spritesmith( | |
{ | |
retinaSrcFilter: 'images-source/*-2x.png', | |
imgName: 'sprite.png', | |
retinaImgName: 'sprite-2x.png', | |
cssName: '../css-source/_sprite.scss', | |
imgPath: '../images/sprite.png', | |
retinaImgPath: '../images/sprite-2x.png' | |
} | |
)) | |
spriteData.pipe(gulp.dest('images/')); | |
}); | |
gulp.task('html', function () { | |
gulp.src('./templates/**/*.html.twig') | |
}); | |
gulp.task('browser-sync', ['sass', 'scripts'], function () { | |
browserSync({ | |
logPrefix: 'My drupal Local site', | |
host: 'mydrupal.drop', | |
// port: 3001, | |
open: false, | |
notify: true, | |
reloadDelay: 2000, | |
}); | |
}); | |
/** consider using this so as not to have to inject the script into an HTML page | |
* // Main watch task. | |
gulp.task('watch', function() { | |
// BrowserSync proxy setup | |
sync.init({ | |
open: false, | |
proxy: 'http://somelocal.dev' | |
}); | |
**/ | |
// Watch Files For Changes. | |
gulp.task('watch', function () { | |
gulp.watch('css-source/**/*.scss', ['sass', browserSync.reload]); | |
gulp.watch('js-source/**/*.js', ['scripts', browserSync.reload]); | |
gulp.watch('images-source/**/*', ['sprite', browserSync.reload]); | |
gulp.watch('templates/**/*.html.twig', ['html', browserSync.reload]); | |
gulp.watch('templates/*.html.twig').on('change', browserSync.reload); | |
}); | |
// Define post tasks (minify and concatinate min). | |
gulp.task('postprocess', function () { | |
return gulp.src(['css/materialize.css', 'css/mmenu.css', 'css/styles.css']) | |
.pipe(sass()) | |
.pipe(stripCssComments()) | |
.pipe(concatCss("bundle.css")) | |
.pipe(cssmin()) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(gulp.dest('css/minicat')) | |
}); | |
// Run the default Tasks. | |
gulp.task('default', function () { | |
gulp.start('sass', 'scripts', 'html', 'sprite', 'browser-sync', 'watch'); | |
}); | |
// Run post task. | |
gulp.task('minicat', function () { | |
gulp.start('postprocess'); | |
}); | |
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
{ | |
"name": "My-theme", | |
"version": "0.0.1", | |
"private": true, | |
"repository": { | |
"type": "git" | |
}, | |
"devDependencies": { | |
"browser-sync": "^2.11.2", | |
"compass-sass-mixins": "^0.12.7", | |
"gulp": "^3.9.1", | |
"gulp-autoprefixer": "^3.1.0", | |
"gulp-concat": "^2.6.0", | |
"gulp-concat-css": "^2.3.0", | |
"gulp-cssmin": "^0.1.7", | |
"gulp-image-resize": "^0.7.1", | |
"gulp-imagemin": "^2.4.0", | |
"gulp-jshint": "^2.0.0", | |
"gulp-livereload": "^3.8.1", | |
"gulp-load-plugins": "^1.2.2", | |
"gulp-minify-css": "^1.2.4", | |
"gulp-newer": "^1.1.0", | |
"gulp-pixrem": "^1.0.0", | |
"gulp-plumber": "^1.1.0", | |
"gulp-rename": "^1.2.2", | |
"gulp-sass": "^2.3.1", | |
"gulp-shell": "^0.5.2", | |
"gulp-sourcemaps": "^1.6.0", | |
"gulp-strip-css-comments": "^1.2.0", | |
"gulp-uglify": "^1.5.3", | |
"gulp.spritesmith": "^6.2.0", | |
"include-media": "^1.4.2", | |
"jshint": "^2.9.1", | |
"load-grunt-tasks": "^3.2.0", | |
"run-sequence": "^1.1.5", | |
"sassline": "^2.1.2", | |
"susy": "^2.2.12", | |
"tiny-lr": "^0.2.1", | |
"typi": "^2.3.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment