perf: tree shaking Bootstrap CSS (#1736)

This commit is contained in:
Cotes Chung
2024-05-11 11:07:48 +08:00
parent ddb48eda52
commit 363a3d936b
13 changed files with 69 additions and 34 deletions

23
purgecss.config.js Normal file
View File

@@ -0,0 +1,23 @@
const fs = require('fs');
const DIST_PATH = '_sass/dist';
fs.rm(DIST_PATH, { recursive: true, force: true }, (err) => {
if (err) {
throw err;
}
fs.mkdirSync(DIST_PATH);
});
module.exports = {
content: ['_includes/**/*.html', '_layouts/**/*.html', '_javascript/**/*.js'],
css: ['node_modules/bootstrap/dist/css/bootstrap.min.css'],
keyframes: true,
variables: true,
output: `${DIST_PATH}/bootstrap.css`,
// The `safelist` should be changed appropriately for future development
safelist: {
standard: [/^collaps/, /^w-/, 'shadow', 'border', 'kbd'],
greedy: [/^col-/, /tooltip/]
}
};