-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
40 lines (40 loc) · 1.49 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
// Load Plugins
const gulp = require('gulp');
const sass = require('gulp-sass');
const rename = require('gulp-rename');
const browsersync = require('browser-sync').create();
// Static Server
function browserSync() {
browsersync.init({
server: {
baseDir: "."
}
});
}
// BrowserSync Reload
function browserSyncReload() {
browsersync.reload();
}
// Watch Files
function watchFiles() {
// If you need to change your directory, change the values below "new_directory/*.scss"
gulp.watch("scss/*.scss", scss); // Watch and build CSS file
gulp.watch("*.html").on('change', browserSyncReload); // Reload when HTML is changed
}
// Compile SCSS into CSS & auto-inject into browsers
function scss() {
// If you need to change your directory, change the values below "new_directory/*.scss"
return gulp.src('scss/*.scss') // Folder directory and file extension
.pipe(sass.sync({outputStyle: 'compressed'}).on('error', sass.logError)) // In OutputStyle select if you want compact,expanded,nested or compressed
.pipe(rename({suffix:'.min'})) // Rename compressed CSS
.pipe(gulp.dest('assets/css')) // Select the directory for the CSS file "new_directory/css"
.pipe(browsersync.stream());
}
// Define Complex Tasks
const build = gulp.series(gulp.parallel(scss));
const start = gulp.parallel(watchFiles, browserSync);
//Export Tasks
exports.scss = scss;
exports.start = start;
exports.build = build;
exports.default = start; // Initialize all tasks