This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
86 lines (72 loc) · 2.07 KB
/
gulpfile.js
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
var gulp = require('gulp');
var del = require('del');
var gulpLoadPlugins = require('gulp-load-plugins');
var bs = require('browser-sync');
var $ = gulpLoadPlugins();
var options = {};
options.rootPath = {
project: __dirname + '/',
theme: __dirname + '/'
};
options.theme = {
root: options.rootPath.theme,
css: options.rootPath.theme + 'css/',
sass: options.rootPath.theme + 'sass/'
};
var sassFiles = [
options.theme.sass + '**/*.scss',
// Do not open Sass partials as they will be included as needed.
'!' + options.theme.sass + '**/_*.scss',
// Hide additional files
'!' + options.theme.sass + 'init/uikit/uikit.scss'
];
// Set the URL used to access the Drupal website under development. This will
// allow Browser Sync to serve the website and update CSS changes on the fly.
options.drupalURL = '';
// options.drupalURL = 'localhost'
var AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
];
// Clean all directories.
gulp.task('clean', ['clean:css']);
// Clean CSS files.
gulp.task('clean:css', function() {
return del([
options.theme.css + '**/*.css',
options.theme.css + '**/*.map'
], {force: true});
});
// Compile and automatically prefix stylesheets
gulp.task('styles', ['clean:css'], function(){
return gulp.src(sassFiles)
.pipe($.sourcemaps.init())
.pipe($.sass({
precision: 10,
outputStyle: 'compressed'
}).on('error', $.sass.logError))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe($.sourcemaps.write('./'))
.pipe($.size({title: 'Styles'}))
.pipe(gulp.dest(options.theme.css));
});
gulp.task('browser-sync', function() {
bs.init({
proxy: options.drupalURL,
open: false
});
});
// Watch files for changes & reload
gulp.task('watch', ['browser-sync'], function(){
gulp.watch([options.theme.sass + '/**/*.scss'], ['styles', bs.reload]);
gulp.watch(['./templates/*.php', './*.php']).on('change', bs.reload);
});
// Watch and reload
gulp.task('default', ['styles', 'watch']);