Skip to content

Instantly share code, notes, and snippets.

@zetagraph
Created November 15, 2014 20:09
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save zetagraph/065f4e026078323606de to your computer and use it in GitHub Desktop.
Save zetagraph/065f4e026078323606de to your computer and use it in GitHub Desktop.
gulp drupal theme
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']);
});
@landsman
Copy link

landsman commented Feb 6, 2018

thanks for gulp-shell :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment