1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-06-13 11:08:05 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Cotes Chung
5269d3ffb0
feat: upgrade sass architecture
- Modularized the Sass architecture to enhance code maintainability and reduce the output file size
- Replaced deprecated `@import` with `@use` / `@forward`
2024-11-24 04:54:09 +08:00
Cotes Chung
c69914effc
ci: avoid repeated runs of stylelint (#2057) 2024-11-24 04:33:46 +08:00
9 changed files with 39 additions and 71 deletions

View File

@ -1,25 +0,0 @@
name: Style Lint
on:
push:
branches:
- master
- "hotfix/*"
paths: ["_sass/**/*.scss"]
pull_request:
paths: ["_sass/**/*.scss"]
jobs:
stylelint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*
- run: npm i
- run: npm test

2
.gitignore vendored
View File

@ -23,5 +23,5 @@ package-lock.json
!.vscode/tasks.json
# Misc
_sass/vendor
_sass/vendors
assets/js/dist

31
.stylelintrc.json Normal file
View File

@ -0,0 +1,31 @@
{
"ignoreFiles": ["_sass/vendors/**"],
"extends": "stylelint-config-standard-scss",
"rules": {
"no-descending-specificity": null,
"shorthand-property-no-redundant-values": null,
"at-rule-no-vendor-prefix": null,
"property-no-vendor-prefix": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null,
"color-function-notation": "legacy",
"alpha-value-notation": "number",
"selector-not-notation": "simple",
"color-hex-length": "long",
"declaration-block-single-line-max-declarations": 3,
"scss/operator-no-newline-after": null,
"rule-empty-line-before": [
"always",
{
"ignore": ["after-comment", "first-nested"]
}
],
"value-keyword-case": [
"lower",
{
"ignoreProperties": ["/^\\$/"]
}
],
"media-feature-range-notation": "prefix"
}
}

View File

@ -1,2 +1,2 @@
@use 'vendor/bootstrap';
@use 'vendors/bootstrap';
@use 'main';

View File

@ -44,7 +44,7 @@
padding: 1rem;
@include bp.md {
padding: 1.75rem 1.75rem 1.25rem 1.75rem;
padding: 1.75rem 1.75rem 1.25rem;
}
.card-title {

View File

@ -68,44 +68,6 @@
]
}
},
"stylelint": {
"ignoreFiles": [
"_sass/vendor/**"
],
"extends": "stylelint-config-standard-scss",
"rules": {
"no-descending-specificity": null,
"shorthand-property-no-redundant-values": null,
"at-rule-no-vendor-prefix": null,
"property-no-vendor-prefix": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null,
"color-function-notation": "legacy",
"alpha-value-notation": "number",
"selector-not-notation": "simple",
"color-hex-length": "long",
"declaration-block-single-line-max-declarations": 3,
"scss/operator-no-newline-after": null,
"rule-empty-line-before": [
"always",
{
"ignore": [
"after-comment",
"first-nested"
]
}
],
"value-keyword-case": [
"lower",
{
"ignoreProperties": [
"/^\\$/"
]
}
],
"media-feature-range-notation": "prefix"
}
},
"release": {
"branches": [
"production"

View File

@ -1,13 +1,13 @@
const fs = require('fs').promises;
const { PurgeCSS } = require('purgecss');
const DIST_PATH = '_sass/vendor';
const DIST_PATH = '_sass/vendors';
const output = `${DIST_PATH}/_bootstrap.scss`;
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'],
@ -20,7 +20,7 @@ function main() {
.then(() => fs.mkdir(DIST_PATH))
.then(() => new PurgeCSS().purge(config))
.then((result) => {
return fs.writeFile(`${DIST_PATH}/bootstrap.scss`, result[0].css);
return fs.writeFile(output, result[0].css);
})
.catch((err) => {
console.error('Error during PurgeCSS process:', err);

View File

@ -92,7 +92,7 @@ init_files() {
npm i && npm run build
# track the CSS/JS output
_sedi "/^_sass\/vendor/d" .gitignore
_sedi "/^_sass\/vendors/d" .gitignore
_sedi "/^assets\/js\/dist/d" .gitignore
}

View File

@ -15,7 +15,7 @@ NODE_SPEC="package.json"
CHANGELOG="docs/CHANGELOG.md"
CONFIG="_config.yml"
CSS_DIST="_sass/vendor"
CSS_DIST="_sass/vendors"
JS_DIST="assets/js/dist"
FILES=(