The font-weight isn’t related here (I tried setting to 300 but it still loaded from a relative path).
I did finally get it working just now though, by giving up on the _fonts.scss
file I had, moving all custom fonts into the tailwind main.css
, like this:
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 100;
src: local('RobotoCondensed-Light'),
url('/fonts/robotocondensed/RobotoCondensed-Light.WOFF?v=10') format('woff2'),
url('/fonts/robotocondensed/RobotoCondensed-Light.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: normal;
src: local('RobotoCondensed-Regular'),
url('/fonts/robotocondensed/RobotoCondensed-Regular.WOFF?v=10') format('woff2'),
url('/fonts/robotocondensed/RobotoCondensed-Regular.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: bold;
src: local('RobotoCondensed-Bold'),
url('/fonts/robotocondensed/RobotoCondensed-Bold.WOFF?v=10') format('woff2'),
url('/fonts/robotocondensed/RobotoCondensed-Bold.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-weight: 100;
src: local('RobotoMono-Thin'),
url('/fonts/robotomono/RobotoMono-Thin.WOFF?v=10') format('woff2'),
url('/fonts/robotomono/RobotoMono-Thin.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-weight: 200;
src: local('RobotoMono-Light'),
url('/fonts/robotomono/RobotoMono-Light.WOFF?v=10') format('woff2'),
url('/fonts/robotomono/RobotoMono-Light.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-weight: 300;
src: local('RobotoMono-Regular'),
url('/fonts/robotomono/RobotoMono-Regular.WOFF?v=10') format('woff2'),
url('/fonts/robotomono/RobotoMono-Regular.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-weight: 400;
src: local('RobotoMono-Medium'),
url('/fonts/robotomono/RobotoMono-Medium.WOFF?v=10') format('woff2'),
url('/fonts/robotomono/RobotoMono-Medium.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto Mono';
font-style: normal;
font-weight: 500;
src: local('RobotoMono-Bold'),
url('/fonts/robotomono/RobotoMono-Bold.WOFF?v=10') format('woff2'),
url('/fonts/robotomono/RobotoMono-Bold.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 100;
src: local('Roboto-Thin'),
url('/fonts/roboto/Roboto-Thin.WOFF?v=10') format('woff2'),
url('/fonts/roboto/Roboto-Thin.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 200;
src: local('Roboto-Light'),
url('/fonts/roboto/Roboto-Light.WOFF?v=10') format('woff2'),
url('/fonts/roboto/Roboto-Light.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: local('Roboto-Regular'),
url('/fonts/roboto/Roboto-Regular.WOFF?v=10') format('woff2'),
url('/fonts/roboto/Roboto-Regular.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: local('Roboto-Medium'),
url('/fonts/roboto/Roboto-Medium.WOFF?v=10') format('woff2'),
url('/fonts/roboto/Roboto-Medium.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: local('Roboto-Bold'),
url('/fonts/roboto/Roboto-Bold.WOFF?v=10') format('woff2'),
url('/fonts/roboto/Roboto-Bold.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 600;
src: local('Roboto-Black'),
url('/fonts/roboto/Roboto-Black.WOFF?v=10') format('woff2'),
url('/fonts/roboto/Roboto-Black.ttf?v=10') format('truetype');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Unica One';
font-style: normal;
font-weight: 200;
src: local('UnicaOne-Regular'),
url('/fonts/unicaone/UnicaOne-Regular.ttf?v=10') format('truetype');
}
@font-face {
font-family: 'Jura';
font-style: normal;
font-weight: 200;
src: local('Jura-VariableFont_wght'),
url('/fonts/jura/Jura-VariableFont_wght.ttf?v=10') format('truetype');
}
}
and modifying tailwind.config.js
as such:
...
theme: {
extend: {
fontFamily: {
'roboto-condensed': ['Roboto Condensed', 'system-ui'],
'roboto-mono': ['Roboto Mono', 'system-ui'],
roboto: ['Roboto', 'Helvetica Neue', 'Arial', 'sans-serif'],
'unica-one': ['Unica One', 'cursive']
},
...
I still retain the mixins I had in _fonts.scss
and those are working now, plus I can do the TailwindCSS font-<font name>
thing, e.g. font-jura
.