如何解决PostCSS:运行任务时,PurgeCSS不起作用
我目前正在尝试从项目的样式表中删除未使用的CSS。我有一个gulp任务sass
,所有编译都已完成。我正在使用postcss和purgecss的插件。但是,当我运行sass
任务purgecss
时似乎不起作用。
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'))
);
上面,如果您注意到purgecss
,我将其传递至应该从中删除CSS的模板的路径。使用PostCSS API following the documentation,添加模板的目录:
const purgecss = require('@fullhuman/postcss-purgecss')
postcss([
purgecss({
content: ['./src/**/*.html']
})
])
除了purgecss
之外,我还应该在content
上添加配置吗?
问题可能是什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。