I Installed the IBM Plex font via yarn add @ibm/plex.
I’ve added import "~@ibm/plex/scss/ibm-plex.scss"; to main.scss.
I’ve added $font-prefix: "~@ibm/plex"; to _variables.scss.
Running yarn build works fine, but when I run yarn build:production I get this error
...
Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve '@ibm/plex ' in '/theme/resources/assets/styles'
...
I found multiple posts detailing differences between build and build:production, but those seem to be not applicable to my situation. Also this post mentions how to use IBM Plex, but it doesn’t work for me .
Hmm… I don’t see a problem in your code at first glance.
Can you provide your config.json (and double check that it’s correct)? The error you provided in your original post is a little odd–it says it’s looking at /theme/resources/assets/styles for the module, which seems like a strange path. I’d expect something like /app/themes/my-theme/resources/assets/styles or /wp-content/themes/my-theme/resources/assets/styles.
I did a test in a vanilla Sage theme using the following, and it’s working on both yarn build and yarn build:production.
Two asides that might be useful once you get it working:
FWIW, you don’t need to declare an @font-face rule since those are included in the SCSS you’re importing from @ibm/plex.
If you’re just using one or two variants of the font, you might want to only import those. For example, if you’re only using Sans, then try @import "~@ibm/plex/scss/sans/index"; instead of @import "~@ibm/plex/scss/ibm-plex";.
Edit: also, even if you did need to write an @font-face, that’s not where you would declare a font stack to be used like you’re doing ("IBM Plex Sans", "Helvetica Neue", Arial, sans-serif). You’d just give the name of the font you’re informing the browser about ('IBM Plex Sans'). You’d put the font stack in your CSS when styling a specific element or set of elements (see the _global.scss example I gave above), or if you’re using Bootstrap you might put it in a variable like $font-family-sans-serif (and then Bootstrap would use it to create the final styles).