Skip to content

Commit

Permalink
Update PurgeCSS to parse .js | 'dist' -> 'prod'
Browse files Browse the repository at this point in the history
  • Loading branch information
notSagyo committed Feb 3, 2022
1 parent 12bec10 commit faed4fd
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ let postCssProcessors = [
lost(),
presetEnv()
];
let postCssDistProcessors = postCssProcessors.concat([(cssnano())]);
let postCssProdProcessors = postCssProcessors.concat([cssnano()]);

//URLs
let paths = {
cssSource: 'src/**',
cssDest: 'dist/css',
htmlSource: ['dist/**/*.html'],
purgeCss: ['dist/**/*.html', 'dist/**/*.js'],
excludeVendor: '!src/**/vendor/**'
};

Expand All @@ -36,15 +36,15 @@ const buildCss = function() {
gulp.task('buildcss', buildCss);
gulp.task('buildCss', buildCss);

const buildCssDist = function() {
const buildCssProd = function() {
return gulp.src([paths.cssSource + '/*.css', paths.excludeVendor])
.pipe(postcss(postCssDistProcessors))
.pipe(purgecss({ content: paths.htmlSource }))
.pipe(postcss(postCssProdProcessors))
.pipe(purgecss({ content: paths.purgeCss }))
.pipe(rename({dirname:''}))
.pipe(gulp.dest(paths.cssDest));
};
gulp.task('buildcssdist', buildCssDist);
gulp.task('buildCssDist', buildCssDist);
gulp.task('buildcssprod', buildCssProd);
gulp.task('buildCssProd', buildCssProd);

const buildSass = function() {
return gulp.src([paths.cssSource + '/*.scss', paths.excludeVendor])
Expand All @@ -58,16 +58,16 @@ const buildSass = function() {
gulp.task('buildSass', buildSass);
gulp.task('buildsass', buildSass);

const buildSassDist = function() {
const buildSassProd = function() {
return gulp.src([paths.cssSource + '/*.scss', paths.excludeVendor])
.pipe(sass().on('error', sass.logError))
.pipe(postcss(postCssDistProcessors))
.pipe(purgecss({ content: paths.htmlSource }))
.pipe(postcss(postCssProdProcessors))
.pipe(purgecss({ content: paths.purgeCss }))
.pipe(rename({dirname:''}))
.pipe(gulp.dest(paths.cssDest));
};
gulp.task('buildSassDist', buildSassDist);
gulp.task('buildsassdist', buildSassDist);
gulp.task('buildSassProd', buildSassProd);
gulp.task('buildsassprod', buildSassProd);

// Watch -------------------------------------------------------------------- //
const watchCss = function() {
Expand Down

0 comments on commit faed4fd

Please sign in to comment.