I'm currently trying to remove unused CSS from a project's stylesheets. I have a gulp task sass
where all the compiling is being done. I'm using postcss and a plugin for purgecss. However, when I run the sass
task purgecss
doesn't seem to be working.
gulp.task('sass', () => gulp.src(`${SRC}/scss/style-*.scss`)
.pipe(sourcemaps.init())
.pipe(gulpSass({
includePaths: ['node_modules', `${PATTERNS_ACCESS}/src/`]
.concat(require('bourbon').includePaths)
})
.on('error', gulpSass.logError))
.pipe(postcss([
purgecss({
content: ['./views/**/*.twig']
}),
autoprefixer(),
mqpacker({sort: true}),
cssnano()
]))
.pipe(hashFilename({format: HASH_FORMAT}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./assets/styles'))
);
Above if you notice purgecss
I pass it the path to to the templates it should remove the css from. Using the PostCSS API following the documentation, I add the directory of the templates:
const purgecss = require('@fullhuman/postcss-purgecss')
postcss([
purgecss({
content: ['./src/**/*.html']
})
])
Is there anything I should add to the configuration on the purgecss
besides content
?
what can the issue be?