Created
November 15, 2014 20:09
-
-
Save zetagraph/065f4e026078323606de to your computer and use it in GitHub Desktop.
gulp drupal theme
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"); | |
var sass = require("gulp-sass"); | |
var filter = require('gulp-filter'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var browserSync = require("browser-sync"); | |
var reload = browserSync.reload; | |
var shell = require('gulp-shell'); | |
// sass task | |
gulp.task('sass', function () { | |
return gulp.src('scss/**/*.scss') | |
.pipe(sourcemaps.init()) | |
.pipe(sass({ | |
//outputStyle: 'compressed', | |
outputStyle: 'nested', | |
precision: 10, | |
onError: function (err) { | |
notify().write(err); | |
} | |
})) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest('css')) | |
.pipe(filter('scss**/*.css')) // Filtering stream to only css files | |
.pipe(browserSync.reload({stream:true})); | |
}); | |
// process JS files and return the stream. | |
gulp.task('js', function () { | |
return gulp.src('js/*js') | |
.pipe(gulp.dest('js')); | |
}); | |
// run drush to clear the theme registry. | |
gulp.task('drush', shell.task([ | |
'drush cache-clear theme-registry' | |
])); | |
// BrowserSynk | |
gulp.task('browser-sync', function() { | |
//watch files | |
var files = [ | |
'css/style.css', | |
'js/*js', | |
'img/**/*', | |
'templates/*.twig' | |
]; | |
//initialize browsersync | |
browserSync.init(files, { | |
//browsersync with a php server | |
proxy: "drupal8.dev", | |
notify: true | |
}); | |
}); | |
// Default task to be run with `gulp` | |
gulp.task('default', ['sass', 'js', 'browser-sync'], function () { | |
gulp.watch("scss/**/*.scss", ['sass']); | |
gulp.watch("js/*.js", ['js']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for gulp-shell :)