Problem/Motivation

Radix sub-theme npm compilation issue

Steps to reproduce

Install the latest 5.0.x version of the theme and follow the steps mentioned in the theme page

  • Download and enable the components module, if you are on Drupal 10 make sure to use
    composer require ^3.0 version:
    
    

    composer require drupal/components
    drush en components -y

  • Download and enable Radix theme:
    composer require drupal/radix; drush then radix
  • Create a sub-theme using Drush (Considering you are using drupal/recommended-project):
    drush --include="web/themes/contrib/radix" radix:create SUBTHEME_NAME
  • Set default theme:
    drush then SUBTHEME_NAME -y; drush config-set system.theme default SUBTHEME_NAME -y
  • Install dependencies:
    cd /path/to/SUBTHEME_NAME
    and then
    npm install
  • Copy the proxy.example.js to proxy.js in the config directory of your subtheme:
    cp config/proxy.example.js config/proxy.js
  • Update proxy variable to your localhost address in config/proxy.js(this file is .gitignored by default to avoid overrides)
    Watch:
    npm run watch

When running npm run watch the following error message appears which stops the SCSS to CSS compilation

module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Undefined variable.
   ╷
56 │     "secondary": $secondary-text-emphasis-dark,

Proposed resolution

This is due to $secondary-text-emphasis-dark is not in the ~bootstrap/scss/variables
This variable is in this file @import "~bootstrap/scss/_variables-dark.scss";
We need to add this in the _init.scss file after this line ~bootstrap/scss/variables

Comments

Mukeysh created an issue. See original summary.

mukeysh’s picture

Status: Active » Needs work
mukeysh’s picture

Adding a patch to fix the issue.

bunty oberoi’s picture

Status: Needs work » Needs review
bunty oberoi’s picture

StatusFileSize
new164.16 KB
new164.16 KB
new39.09 KB

Hi Mukeysh,

Verified and tested Patch Comment #3 on Drupal Version 10.1.0-dev & PHP Version 8.1.16

Testing Steps:-
1). Install Drupal 10.1.0 version.
2). git clone --branch '5.0.x' https://git.drupalcode.org/project/radix.git
Followed the above steps given
3). Applied Patch #3 /projects/drupal/themes/contrib/radix/3363752-radix-subtheme-npm-compilation-issue.patch
4). Checked the changes difference using git diff
5). Installed theme and set it as default.
6). Run Command npm run watch

Testing result:
Patch Comment #3 fixed the issue
Here I have attached the before and after apply patch screenshots.
Moved the issue to RTBC ++

bunty oberoi’s picture

bunty oberoi’s picture

bunty oberoi’s picture

StatusFileSize
new27.35 KB
morbus iff’s picture

I think just

@import '~bootstrap/scss/variables-dark';

would be the better approach, right?

shyam_bhatt’s picture

StatusFileSize
new428 bytes
new442.69 KB
new271.43 KB

Updated the @import '~bootstrap/scss/variables-dark'; instead of @import "~bootstrap/scss/_variables-dark.scss"; on the same file for better code practice and creating a new patch.

I have checked the patch and added the after and before screenshots.

Please refer #5 steps for the testing. Needs review

shyam_bhatt’s picture

After creating SUB_THEME, Go to theme path "cd /path/to/SUBTHEME_NAME" and then run npm install.

When running npm run watch the following error message appears which stops the SCSS to CSS compilation.
After updating the @import '~bootstrap/scss/variables-dark'; instead of @import "~bootstrap/scss/_variables-dark.scss"; found some errors as below:

2023-06-15/3363752-complilation-error.png

To fix this I have updated the new patch. Please check the patch and the after image for the same.

Needs review.

doxigo’s picture

Status: Needs review » Fixed

Thanks everyone for the work here, the correct approach would be to do @import "~bootstrap/scss/variables-dark";

Fixed on the dev version for now, will release a new tag shortly, great work everyone

  • doxigo committed fcd6588b on 5.0.x authored by Shyam_Bhatt
    Issue #3363752 by Shyam_Bhatt, Mukeysh, bunty oberoi, Morbus Iff, doxigo...
doxigo’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.