mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-06-13 19:22:13 +00:00

- Modularized the Sass architecture to enhance code maintainability and reduce the output file size - Replaced deprecated `@import` with `@use` / `@forward`
31 lines
901 B
JavaScript
31 lines
901 B
JavaScript
const fs = require('fs').promises;
|
|
const { PurgeCSS } = require('purgecss');
|
|
const DIST_PATH = '_sass/vendor';
|
|
|
|
const config = {
|
|
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/]
|
|
}
|
|
};
|
|
|
|
function main() {
|
|
fs.rm(DIST_PATH, { recursive: true, force: true })
|
|
.then(() => fs.mkdir(DIST_PATH))
|
|
.then(() => new PurgeCSS().purge(config))
|
|
.then((result) => {
|
|
return fs.writeFile(`${DIST_PATH}/bootstrap.scss`, result[0].css);
|
|
})
|
|
.catch((err) => {
|
|
console.error('Error during PurgeCSS process:', err);
|
|
});
|
|
}
|
|
|
|
main();
|