Fonts not loaded in production builds (since upgrade to Bud 6.2.0)


I updated bud 5.7.7 to 6.2.0.
Previously I was able to load fonts as follows:

@font-face {
  font-family: 'd-dindin-bold';
  src: url('~@fonts/monotype-dinnextltpro-bold.woff2') format('woff2'),
       url('~@fonts/monotype-dinnextltpro-bold.woff') format('woff');

This still works fine in dev mode, but not when I build for production.

These are the kind of errors I get:

downloadable font: download failed [..]  source:

Did something change since Bud 5.7.7 that causes this?

Ok, I think adding


to bud.config.js solved my problem

FWIW setting .setPublicPath('../') worked for me (see [bug] Asset paths in CSS break if publicPath isn’t defined in bud.config.mjs when upgrading to Bud 6.1 · Issue #1547 · roots/bud · GitHub for more info).

This particular issue is resolved in 6.3.0, but it can be resolved in any version by just setting the public path. What is the rationale for being so averse to it?

There is a reason are reasons why it is a near universal requirement of all major popular frameworks. See 6.3.0 release notes for more on this:

The only case where a public path should be an issue is if you are distributing a theme (since you can’t control the public path of the wordpress that is using it). If you’re distributing a theme you have earned a pardon.

To re-iterate what @kellymears said, the proper solution to this is to set the public path. This is now a requirement moving forward in Sage 10, and was always required in Sage 9. See the PR or the latest Bud config in Sage 10 for an example.

     * URI of the `public` directory

Thanks for adding .setPublicPath to the newest Sage release as default. That will definitely help new users.