From b35b11b80717d87a56aa9072ffbc325b930666e8 Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 3 Jul 2023 12:58:49 -0500 Subject: [PATCH] More accurately replicate bslib's Sass code --- configuration | 2 +- .../src/common/update-html-dependencies.ts | 67 +++++++++++++------ 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/configuration b/configuration index ca4ebf4fd1..b0482eb9fb 100644 --- a/configuration +++ b/configuration @@ -17,7 +17,7 @@ export TYPST=0.5.0 # Bootstrap dependencies from bslib # (use commit hash from bslib repo) -export BOOTSTRAP=8dc31b40bd9b387c4a3c36ac1f63bb853037cba6 +export BOOTSTRAP=2ce8eebf06910da5d0719c7a05b9860db5da8c0f export BOOTSTRAP_FONT=1.10.5 export BOOTSWATCH=5.2.3 diff --git a/package/src/common/update-html-dependencies.ts b/package/src/common/update-html-dependencies.ts index 1a72895d4b..6cda8fa7e6 100644 --- a/package/src/common/update-html-dependencies.ts +++ b/package/src/common/update-html-dependencies.ts @@ -586,14 +586,43 @@ async function updateBootstrapFromBslib( // Checkout the appropriate version await repo.checkout(commit); - // Copy the scss files - info("Copying scss files"); - const from = join(repo.dir, "inst", "lib", "bs5", "scss"); - const to = join(distDir, "scss"); - info(`Copying ${from} to ${to}`); - copySync(from, to); - - // Fix up the Boostrap rules files + const copySyncVerbose = (msg: string, from: string, to: string) => { + info(msg); + info(`Copying ${from} to ${to}`); + copySync(from, to); + }; + + copySyncVerbose( + "Copying Bootstrap 5 scss files", + join(repo.dir, "inst", "lib", "bs5", "scss"), + join(distDir, "scss") + ); + + copySyncVerbose( + "Copying bslib's component scss", + join(repo.dir, "inst", "components"), + join(distDir, "scss", "components") + ); + + copySyncVerbose( + "Copying bslib's BS3 compat", + join(repo.dir, "inst", "bs3compat"), + join(distDir, "scss", "bs3compat") + ); + + copySyncVerbose( + "Copying bslib's Sass utilities", + join(repo.dir, "inst", "sass-utils"), + join(distDir, "scss", "sass-utils") + ); + + copySyncVerbose( + "Copying bslib's nav-spacer", + join(repo.dir, "inst", "nav-spacer"), + join(distDir, "scss", "nav-spacer") + ); + + // Fix up the Bootstrap rules files info( "Rewriting bootstrap.scss to exclude functions, mixins, and variables.", ); @@ -602,23 +631,21 @@ async function updateBootstrapFromBslib( '@import "variables";', '@import "mixins";', ]; - const bootstrapScssFile = join(to, "bootstrap.scss"); - const bootstrapScssContents = lines( - Deno.readTextFileSync(bootstrapScssFile), - ).filter((line: string) => { + const bslibScss = Deno.readTextFileSync( + join(repo.dir, "inst", "css-precompiled", "5", "bootstrap.scss") + ); + const bslibScssPatched = lines(bslibScss).filter((line: string) => { + line = line.replace('@import "inst/lib/bs5/scss/', '@import "scss/'); + line = line.replace('@import "inst/', '@import "scss/'); return !bootstrapFilter.includes(line); }).join("\n"); - Deno.writeTextFileSync(bootstrapScssFile, bootstrapScssContents); + Deno.writeTextFileSync( + join(repo.dir, "bootstrap.scss"), + bslibScssPatched + ); info("done."); info(""); - // Copy utils - info("Copying scss files"); - const utilsFrom = join(repo.dir, "inst", "sass-utils"); - const utilsTo = join(distDir, "sass-utils"); - info(`Copying ${utilsFrom} to ${utilsTo}`); - copySync(utilsFrom, utilsTo); - // Grab the js file that we need info("Copying dist files"); [