fix(build): compile the entry points, not the whole scss tree - #692
Merged
Conversation
css-compile ran `sass scss/:dist/css/`, which compiles every file in the
tree that is not a partial. The v6 reorganisation added barrel files -
scss/{buttons,content,forms,helpers,layout,mixins}/index.scss, pure
@forward aggregators - so each of them became an entry point and emitted a
stylesheet of its own: 24 files, 157 kB before minification, including a
39-byte mixins/index.css and a forms/index.css that is a second copy of
the forms layer.
They were not gitignored and `files` ships dist/css/**, so they were
headed for npm.
Naming the five real entry points is what upstream Bootstrap does for the
same reason. Verified: all five compile byte-identical to what directory
mode produced.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dist/csshad six folders in it that nobody asked for.What happened
css-compileran in directory mode:which compiles every file in the tree that is not a partial. The v6 reorganisation added barrel files —
scss/{buttons,content,forms,helpers,layout,mixins}/index.scss, pure@forwardaggregators — and because they have no leading underscore, each became an entry point and emitted a stylesheet of its own.The result, per build:
index.cssforms/buttons/content/layout/helpers/mixins/24 files with their minified variants and source maps, roughly 157 kB before minification. They were not gitignored, and
filesshipsdist/{css,js}/**/*.{css,js,map}— so they were headed for the published package, source maps and all (and--embed-sourcesputs the full Sass into those).The fix
Name the five real entry points, which is exactly what upstream Bootstrap does — their
css-compilelistsbootstrap.scss,bootstrap-grid.scss,bootstrap-reboot.scssandbootstrap-utilities.scss, and theirscss/forms/index.scssandscss/helpers/index.scssbarrels are spelled the same way ours are. Directory mode was the difference, not the file naming — worth keeping in mind, since renaming the barrels to_index.scsswould have diverged from a structure we deliberately track.Verification
Compiled the same tree both ways and diffed:
Byte-identical, all five. The only difference in the output tree is the six barrels that stop being written.
Plus stylelint, bundlewatch and the local pre-push gate (lint → dist → typecheck → sass suite → class API → bundlewatch → js tests).