Skip to content

npm-dep modernization: source Bootstrap and Font Awesome from npm - #2670

Merged
chalin merged 11 commits into
docsy:mainfrom
chalin:chalin-m24-npm-dep-modernization-2026-0629
Jun 30, 2026
Merged

chalin merged 11 commits into
docsy:mainfrom
chalin:chalin-m24-npm-dep-modernization-2026-0629

Conversation

@chalin

@chalin chalin commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator
  • Contributes to npm-dep modernization: adopt Hugo's first-class npm-module support for Bootstrap/Font-Awesome #2668
  • Preview(s):
  • Sources Bootstrap and Font Awesome from npm instead of importing their GitHub repos as Hugo modules — a workaround, since neither publishes a Go module. Hugo's first-class npm-module support (hugo mod npm pack) makes the imports redundant, so theme/package.json becomes the single source of truth and also carries the PostCSS toolchain.
    • Drops the two imports from theme/hugo.yaml, the generated theme/go.mod requires and theme/go.sum, and the scripts/getHugoModules/ generator with its get:hugo-modules prepare step.
    • Retires the obsolete Bootstrap rfs vendor workaround (theme/assets/_vendor/, _cp:bs-rfs), which existed only because Go omits vendor/ subdirectories from module dependencies (cmd/go: non-top-level packages ending in "/vendor" are omitted from module zip files golang/go#37397); the npm mount carries scss/vendor/_rfs.scss directly.
  • Breaking for Hugo-module sites: they now run hugo mod npm pack and npm install to pull the theme's npm deps (Bootstrap, Font Awesome, PostCSS). npm-package and clone/submodule sites are unaffected — deps still come via Docsy's postinstall. Documented in the 0.16.0 release report and changelog.
  • Validated: docsy.dev builds byte-identical vendored CSS, JS, and webfonts; the make-site smoke matrix (NPM, Hugo module, clone) is green for all three install methods across Linux and Windows, with the Hugo-module path adapted to the hugo mod npm pack flow.

- Bootstrap and Font-Awesome were pulled in as Hugo-module `imports` of their GitHub repos — a workaround, since neither publishes a Go module. Hugo's first-class npm-module support (>= 0.159, `hugo mod npm pack`) makes that redundant: the existing `node_modules/*` mounts resolve project-relative, so consumers source both from the theme's declared npm deps.
- Drops the two imports from `theme/hugo.yaml`; removes the generated `theme/go.mod` requires and `theme/go.sum`, the `scripts/getHugoModules/` generator, and its `get:hugo-modules` step in `_prepare`.
- Adds the PostCSS toolchain (autoprefixer, postcss, postcss-cli) to `theme/package.json` so Hugo-module consumers get it via `hugo mod npm pack` instead of installing it manually.
- docsy.dev builds byte-identical vendored CSS, JS, and webfonts.
@chalin
chalin force-pushed the chalin-m24-npm-dep-modernization-2026-0629 branch from b1f4f02 to c399474 Compare June 30, 2026 01:50
chalin added 5 commits June 30, 2026 09:36
- The Hugo-module smoke path now runs `hugo mod npm pack && npm install` to pull the theme's npm deps (Bootstrap, Font-Awesome, PostCSS tooling), replacing the manual PostCSS install — mirroring how downstream Hugo-module sites consume Docsy now that the BS/FA imports are gone.
- `theme/assets/_vendor/bootstrap/scss/_rfs.scss` and its sync step (`_cp:bs-rfs`) worked around a Go-module bug (golang/go#37397, golang/go#71785): Go omits `vendor/` subdirectories when fetching a dependency as a module, so the former Bootstrap Hugo-module import dropped `scss/vendor/_rfs.scss`.
- Now that Bootstrap is sourced from npm, the `node_modules/bootstrap` mount carries `scss/vendor/_rfs.scss` directly, so the committed copy, its `assets/vendor/bootstrap/scss/vendor` mount, and the `_cp:bs-rfs` prepare step are no longer needed.
- docsy.dev builds byte-identical vendored CSS.
- Adds a release-report section and a changelog entry for sourcing Bootstrap and Font Awesome from npm: the upgrade action for Hugo-module sites (`hugo mod npm pack` then `npm install`), with a note that npm-package and clone/submodule sites are unaffected.
mkdirp-hugo-mod.js created empty node_modules/github.com/<path> stub dirs so
non-module consumers wouldn't choke on the theme's github.com Hugo-module
imports. Sourcing Bootstrap and Font Awesome from npm removed those imports, so
theme/go.mod no longer has any github.com requires and the script creates
nothing.

Remove the script, its _mkdir:hugo-mod npm task and the now-redundant
_postinstall indirection (postinstall runs install:theme-deps directly), the
npm-pack contract entry, and the two test harnesses that invoked it.
test:smoke built sites under the repo's own tmp/, so Node could resolve the
repo's node_modules and let a packaging gap pass locally even though a clean CI
checkout would fail. Build under the OS temp dir instead, and pin HUGO to the
repo's installed binary so only the build tool — not the dependencies under
test — is borrowed from the repo.

CI smoke (smoke.yaml) runs from a clean checkout and is unaffected.
@chalin
chalin force-pushed the chalin-m24-npm-dep-modernization-2026-0629 branch from c399474 to 8605307 Compare June 30, 2026 13:37
chalin added 2 commits June 30, 2026 16:07
…deps

- Runs `postCSS` for a non-RTL production build only when the site provides a project-root `postcss.config.{js,mjs,cjs}`; otherwise the Sass output is used as-is. RTL still runs `postCSS` for `rtlcss`.
- Fixes a latent footgun: the unconditional production `postCSS` call required the PostCSS toolchain on every site yet did nothing without a config — the repo-root config stopped being discovered after the monorepo/theme-folder restructure, so autoprefixing had silently become a no-op.
- Drops `autoprefixer`/`postcss`/`postcss-cli` from `theme/package.json` (reversing the bundling added earlier in this branch) and the now-unused `autoprefixer`/`postcss-cli` from `docsy.dev`; deletes the orphaned root `postcss.config.js`.
- Stops `make-site.sh` and the smoke clone test from installing PostCSS for non-RTL sites.
- Adds a fixture-site test locking the gate: a non-RTL production build succeeds with no PostCSS toolchain, and a project-root config opts the pass back in.
- Adds a release-report section and changelog entry: non-RTL sites no longer need a PostCSS toolchain, can drop `autoprefixer`/`postcss`/`postcss-cli`, and opt back in with a project-root `postcss.config.js`; Docsy's CSS targets the Browserslist `defaults` browsers.
- Corrects the npm-deps section to stop claiming the theme ships the PostCSS toolchain, and removes the obsolete clone-install PostCSS step.
- Fixes the RTL docs to list the full toolchain the RTL transform needs (`rtlcss` plus `postcss`/`postcss-cli`/`autoprefixer`), which Docsy no longer bundles.
- Seeds the new Browserslist link into `.lycheecache`.
@chalin
chalin force-pushed the chalin-m24-npm-dep-modernization-2026-0629 branch from 1dbd57c to 24b311d Compare June 30, 2026 20:14
@chalin
chalin marked this pull request as ready for review June 30, 2026 23:08
chalin added 3 commits June 30, 2026 19:18
- Restores the `_postinstall` npm target (sometimes invoked directly) and routes `postinstall` through it again.
- Trims the `head-css.html` PostCSS comment to the non-obvious intent; the branches already read clearly.
- Updates the now-stale fixture `build-site.mjs` comment: the symlinked `node_modules` provides the theme's Bootstrap/Font Awesome SCSS, not PostCSS.
- Leads the release-report and changelog npm-deps items with the Hugo-module scope, so non-module installs see up front that the change doesn't apply to them.
- Phrases the PostCSS change as "sites with RTL languages" rather than "RTL languages".
- Drops the redundant `postcss` from the RTL install command (it comes in as a peer of `postcss-cli`/`autoprefixer`) and links the `rtlcss` package.
- Corrects the release-report wording: the theme keeps `go.mod`; only its generated module requires are retired.
`npm run postinstall` can be invoked directly without triggering other lifecycle scripts, so the separate `_postinstall` target isn't needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant