Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More accurately replicate bslib's Sass code #6099

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configuration
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
67 changes: 47 additions & 20 deletions package/src/common/update-html-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
);
Expand All @@ -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");
[
Expand Down