-
Notifications
You must be signed in to change notification settings - Fork 12
/
gulpfile.js
28 lines (24 loc) · 929 Bytes
/
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
// Initialize modules
const { src, dest, watch, series, parallel } = require('gulp');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const postcss = require('gulp-postcss');
const sass = require('gulp-sass');
// File path variables
const files = {
scssPath: 'src/scss/**/*.scss',
cssPath: 'src/dist/css'
}
// Sass task: compiles the style.scss file into style.css
function scssTask() {
return src(files.scssPath, { sourcemaps: true })
.pipe(sass()) // compile SCSS to CSS
.pipe(postcss([autoprefixer(), cssnano()])) // PostCSS plugins
.pipe(dest(files.cssPath, { sourcemaps: '.' }));
}
// Watch task: watch SCSS files for changes.If any change, run scss and other tasks simultaneously
function watchTask() {
watch([files.scssPath], parallel(scssTask));
}
// Export the default Gulp task so it can be run
exports.default = series(scssTask, watchTask);