mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
Apply suggestions from code review
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
This commit is contained in:
@@ -3,19 +3,20 @@
|
||||
// ==========================================================================
|
||||
// Help: https://css-tricks.com/snippets/css/complete-guide-grid/
|
||||
//
|
||||
// How to use :
|
||||
/**
|
||||
*```html
|
||||
* <div class="o-grid -col-4 -col-12@from-medium -gutters">
|
||||
* <div class="o-grid_item u-gc-1/2 u-gc-3/9@from-medium">
|
||||
* <p>Hello</p>
|
||||
* </div>
|
||||
* <div class="o-grid_item u-gc-3/4 u-gc-9/13@from-medium">
|
||||
* <p>Hello</p>
|
||||
* </div>
|
||||
* </div>
|
||||
* ```
|
||||
**/
|
||||
* Usage:
|
||||
*
|
||||
* ```html
|
||||
* <div class="o-grid -col-4 -col-12@from-medium -gutters">
|
||||
* <div class="o-grid_item u-gc-1/2 u-gc-3/9@from-medium">
|
||||
* <p>Hello</p>
|
||||
* </div>
|
||||
* <div class="o-grid_item u-gc-3/4 u-gc-9/13@from-medium">
|
||||
* <p>Hello</p>
|
||||
* </div>
|
||||
* </div>
|
||||
* ```
|
||||
*/
|
||||
|
||||
.o-grid {
|
||||
display: grid;
|
||||
|
||||
@@ -146,7 +146,7 @@ export default async function compileStyles(sassOptions = null, postcssOptions =
|
||||
await writeFile(outfile, result.css).then(() => {
|
||||
// Purge CSS once file exists.
|
||||
if (outfile) {
|
||||
purgeUnusedCSS(outfile, filestem);
|
||||
purgeUnusedCSS(outfile, `${label || `${filestem}.css`}`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -220,33 +220,35 @@ function createPostCSSProcessor(pluginsListOrMap, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge unused styles of minified CSS files.
|
||||
* Purge unused styles from CSS files.
|
||||
*
|
||||
* @async
|
||||
*
|
||||
* @param {string} outfile - The path of the CSS file.
|
||||
* @param {string} filestem - The CSS file name.
|
||||
* @param {string} outfile - The path of a css file
|
||||
* If missing the function stops.
|
||||
* @param {string} label - The CSS file label or name.
|
||||
* @return {Promise}
|
||||
*/
|
||||
async function purgeUnusedCSS(outfile, filestem) {
|
||||
|
||||
async function purgeUnusedCSS(outfile, label) {
|
||||
label = label ?? basename(outfile);
|
||||
const timeLabel = `${filestem}.css purged in`;
|
||||
console.time(timeLabel);
|
||||
console.time(timeLabel);
|
||||
|
||||
const purgeCSSContentFiles = Array.from(loconfig.tasks.purgeCSS.content);
|
||||
|
||||
const purgeCSSResults = await new PurgeCSS().purge({
|
||||
content: purgeCSSContentFiles,
|
||||
css: [outfile],
|
||||
css: [ outfile ],
|
||||
rejected: true,
|
||||
defaultExtractor: content => content.match(/[a-z0-9_\-\\\/\@]+/gi) || [],
|
||||
safelist: {
|
||||
standard: [/^((?!\bu-gc-).)*$/]
|
||||
standard: [ /^((?!\bu-gc-).)*$/ ]
|
||||
}
|
||||
})
|
||||
|
||||
for(let result of purgeCSSResults) {
|
||||
await writeFile(outfile, result.css)
|
||||
|
||||
message(`${filestem}.css purged`, 'chore', timeLabel);
|
||||
message(`${label} purged`, 'chore', timeLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
# Grid system
|
||||
|
||||
* [Architectures](#architectures)
|
||||
* [Styles](#styles)
|
||||
* [Architectures](#architecture)
|
||||
* [Build tasks](#build-tasks)
|
||||
* [Config file](#config-file)
|
||||
* [Configuration](#configuration)
|
||||
* [Usage](#usage)
|
||||
* [Example](#example)
|
||||
* [Limitations](#limitations)
|
||||
|
||||
## Architecture
|
||||
|
||||
|
||||
Reference in New Issue
Block a user