forked from drupalwxt/wxt_bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
73 lines (56 loc) · 1.72 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
/**
* @file
*
* Defines gulp tasks to be run by Gulp task runner.
*/
/* eslint-env node */
var gulp = require('gulp');
// ========== CONFIG ==========
var sassSrcDir = 'sass';
var sassDestDir = 'css';
// Patterns that Sass should watch for reprocessing.
// Glob pattern documentation: https://github.com/isaacs/node-glob.
var sassWatchPatterns = [
sassSrcDir + '/**.scss'
];
// Host:port that the backend server (Apache, Nginx..) is listening on.
var reloadBackend = 'localhost:8081';
// Port used for main web connection.
var reloadFrontendPort = 8080;
// Patterns that reload server should watch for changes.
// Note: Any stylesheet compiled by Sass shouldn't need to be watched here
// because they should be injected into the HTML automatically by the
// 'sass' task.
var reloadWatchPatterns = [
'/**/*.@(png|jpe?g|gif|ico|svg|tiff)'
];
// ========== SASS ==========
var sass = require('gulp-sass');
gulp.task('sass', function () {
'use strict';
return gulp.src(sassSrcDir + '/*.scss')
.pipe(sass(/*{outputStyle: 'compressed'}*/).on('error', sass.logError))
.pipe(gulp.dest(sassDestDir))
.pipe(browserSync.stream());
});
gulp.task('sass:watch', ['sass'], function () {
'use strict';
gulp.watch(sassWatchPatterns, ['sass']);
});
// ========== BROWSER-SYNC / RELOAD ==========
var browserSync = require('browser-sync');
var reload = browserSync.reload;
gulp.task('browser-sync', function() {
'use strict';
browserSync({
proxy: reloadBackend,
port: reloadFrontendPort,
open: true,
notify: false
});
});
// ========== MAIN WATCH ==========
gulp.task('watch', ['browser-sync', 'sass:watch'], function () {
'use strict';
gulp.watch(reloadWatchPatterns, reload);
});