-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (49 loc) · 1.43 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
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const globImporter = require('sass-glob-importer');
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const browserSync = require('browser-sync').create();
// Define paths
const paths = {
php: './docroot/**/*.php',
scss: './docroot/scss/**/*.scss',
js: './docroot/js/**/*.js',
cssDest: './docroot/css'
};
// Compile SCSS into CSS
function style() {
return gulp.src(paths.scss)
.pipe(sass({
includePaths: ['node_modules/breakpoint-sass/stylesheets'],
importer: globImporter()
}).on('error', sass.logError))
.pipe(postcss([autoprefixer(), cssnano()]))
.pipe(gulp.dest(paths.cssDest))
.pipe(browserSync.stream());
}
// Initialize BrowserSync
function browserSyncInit(done) {
browserSync.init({
proxy: 'https://sass-example.ddev.site/', // Replace with your local development URL
open: true,
notify: false
});
done();
}
// Reload the browser
function reload(done) {
browserSync.reload();
done();
}
// Watch files
function watchFiles() {
gulp.watch(paths.scss, style);
gulp.watch([paths.js, paths.php], gulp.series(reload));
}
// Define complex tasks
const watch = gulp.parallel(watchFiles, browserSyncInit);
// Export tasks
exports.style = style;
exports.watch = watch;