-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
92 lines (82 loc) · 2.05 KB
/
Copy pathgulpfile.js
File metadata and controls
92 lines (82 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var browserSync = require('browser-sync');
var bower = require('gulp-bower');
var reload = browserSync.reload;
var config = {
bowerDir: './scripts/vendor/'
}
// Error notifications
var reportError = function(error) {
$.notify({
title: 'Ha ocurrido un Error!!!',
message: 'Error.'
}).write(error);
console.log(error.toString());
this.emit('end');
}
// Sass processing
gulp.task('sass', function() {
return gulp.src('scss/**/*.scss')
.pipe($.sourcemaps.init())
// Convert sass into css
.pipe($.sass({
outputStyle: 'nested', // libsass doesn't support expanded yet
precision: 10
}))
// Show errors
.on('error', reportError)
// Autoprefix properties
.pipe($.autoprefixer({
browsers: ['last 2 versions']
}))
// Write sourcemaps
.pipe($.sourcemaps.write())
// Save css
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest(config.bowerDir))
});
// process JS files and return the stream.
gulp.task('js', function () {
return gulp.src('scripts/**/*.js')
.pipe(gulp.dest('scripts'));
});
// Run drush to clear the theme registry
gulp.task('drush', function() {
return gulp.src('', {
read: false
})
.pipe($.shell([
'drush cr css-js',
]))
.pipe($.notify({
title: "Caches cleared",
message: "Drupal CSS/JS caches cleared.",
onLast: true
}));
});
// BrowserSync
gulp.task('browser-sync', function() {
//watch files
var files = [
'css/main.css',
'scripts/**/*.js',
'templates/**/*.twig'
];
//initialize browsersync
browserSync.init(files, {
proxy: "d8.dd:8083" // BrowserSync proxy, change to match your local environment
});
});
// Default task to be run with `gulp`
gulp.task('default', ['sass', 'browser-sync'], function() {
gulp.watch("scss/**/*.scss", ['sass']);
gulp.watch("scripts/**/*.js", ['js']);
});