Problem/Motivation
In bs_base 2.0.x, package.json has "build-icons": "node build-icons.js", and the build script runs build-icons before the CSS build. drush bs-tc copies package.json and .fantasticonrc.js into the new child theme, but not build-icons.js, because that file is missing from the list in BsLibCommands::copyThemeFiles().
As a result, npm run build and drush bs-tb fail in every new child theme with Cannot find module .../build-icons.js. The Sass build then fails on @import "variables/icons", because build-icons.js generates that file. No CSS is written, and the site renders unstyled.
Steps to reproduce
drush bs-tc bs_base mytheme "My theme" "My theme"- In the new theme folder, run
npm run build. - The build fails with
Cannot find module .../mytheme/build-icons.js, and nocss/folder is written.
Proposed resolution
Add 'build-icons.js', to the $files list in BsLibCommands::copyThemeFiles(), next to .fantasticonrc.js. The file is copied only if it exists in the parent theme, so parent themes without it are not affected.
This is an interim fix. #3628146: Share build-icons.js, the fantasticon config and template, and gulpfile.js code with child themes instead of copying them proposes that child themes use the icon build code and the gulpfile.js code from bs_base instead of copying them. Once that lands, bs-tc needs these changes:
- Stop copying
build-icons.jsand.fantasticonrc.js. - Copy only
fantasticon/icons.jsonfrom thefantasticonfolder, and no longerfantasticon/scss.hbs. - Remove
gulpfile.jsfrom the search and replace inBsLibCommandsthat changes the parent's machine name to the child's. The newgulpfile.jsfinds bs_base by the namebs_baseingulp-options.yml. For a child theme of bs_base, the replacement would change that name to the child's, and the build would fail.
Remaining tasks
- Add
build-icons.jsto the copy list. - Make the follow-up changes above once #3628146: Share build-icons.js, the fantasticon config and template, and gulpfile.js code with child themes instead of copying them lands.
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork bs_lib-3628148
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
pivica commentedFixed.