Skip to content

Commit

Permalink
Implement sourcemaps and default task
Browse files Browse the repository at this point in the history
  • Loading branch information
notSagyo committed Jan 31, 2022
1 parent ef387d3 commit 6896b42
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let postcss = require('gulp-postcss');
let sass = require('gulp-sass')(require('sass'));
let rename = require('gulp-rename')
let purgecss = require('gulp-purgecss')
let sourcemaps = require('gulp-sourcemaps');
// PostCSS packages
let cssnano = require('cssnano');
let presetEnv = require('postcss-preset-env');
Expand Down Expand Up @@ -47,10 +48,12 @@ gulp.task('buildCssDist', buildCssDist);

const buildSass = function() {
return gulp.src([paths.cssSource + '/*.scss', paths.excludeVendor])
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(postcss(postCssProcessors))
.pipe(sourcemaps.write(''))
.pipe(rename({dirname:''}))
.pipe(gulp.dest(paths.cssDest))
.pipe(gulp.dest(paths.cssDest));
};
gulp.task('buildSass', buildSass);
gulp.task('buildsass', buildSass);
Expand All @@ -61,20 +64,27 @@ const buildSassDist = function() {
.pipe(postcss(postCssDistProcessors))
.pipe(purgecss({ content: paths.htmlSource }))
.pipe(rename({dirname:''}))
.pipe(gulp.dest(paths.cssDest))
.pipe(gulp.dest(paths.cssDest));
};
gulp.task('buildSassDist', buildSassDist);
gulp.task('buildsassdist', buildSassDist);

// Watch -------------------------------------------------------------------- //
const watchCss = function(){
gulp.watch(paths.cssSource + '/*.css', gulp.series(['buildCss']))
const watchCss = function() {
gulp.watch(paths.cssSource + '/*.css', gulp.series(['buildCss']));
};
gulp.task('watchCss', watchCss);
gulp.task('watchcss', watchCss);

const watchSass = function(){
gulp.watch(paths.cssSource + '/*.scss', gulp.series(['buildSass']))
const watchSass = function() {
gulp.watch(paths.cssSource + '/*.scss', gulp.series(['buildSass']));
};
gulp.task('watchSass', watchSass);
gulp.task('watchsass', watchSass);

// Default ------------------------------------------------------------------ //
function defaultTask() {
watchSass();
}

exports.default = defaultTask;

0 comments on commit 6896b42

Please sign in to comment.