Unverified Commit cc0c85e5 authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Default font config fix (#42235)

Fixes typo and makes sure both loaders always have a default value.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent b7ea0a5a
...@@ -90,8 +90,6 @@ export function setHttpClientAndAgentOptions(config: NextConfig) { ...@@ -90,8 +90,6 @@ export function setHttpClientAndAgentOptions(config: NextConfig) {
} }
async function setFontLoaderDefaults(config: NextConfigComplete, dir: string) { async function setFontLoaderDefaults(config: NextConfigComplete, dir: string) {
if (config.experimental?.fontLoaders) return
// Add @next/font loaders by default if they're installed // Add @next/font loaders by default if they're installed
const hasNextFontDependency = ( const hasNextFontDependency = (
await getDependencies({ await getDependencies({
...@@ -114,14 +112,14 @@ async function setFontLoaderDefaults(config: NextConfigComplete, dir: string) { ...@@ -114,14 +112,14 @@ async function setFontLoaderDefaults(config: NextConfigComplete, dir: string) {
} }
if ( if (
!config.experimental.fontLoaders.find( !config.experimental.fontLoaders.find(
({ loader }: any) => loader === '@next/font/goggle' ({ loader }: any) => loader === googleFontLoader.loader
) )
) { ) {
config.experimental.fontLoaders.push(googleFontLoader) config.experimental.fontLoaders.push(googleFontLoader)
} }
if ( if (
!config.experimental.fontLoaders.find( !config.experimental.fontLoaders.find(
({ loader }: any) => loader === '@next/font/local' ({ loader }: any) => loader === localFontLoader.loader
) )
) { ) {
config.experimental.fontLoaders.push(localFontLoader) config.experimental.fontLoaders.push(localFontLoader)
......
module.exports = { module.exports = {
experimental: { experimental: {
appDir: true, appDir: true,
fontLoaders: [],
}, },
} }
...@@ -3,8 +3,7 @@ module.exports = { ...@@ -3,8 +3,7 @@ module.exports = {
experimental: { experimental: {
fontLoaders: [ fontLoaders: [
{ {
loader: '@next/font/google', loader: '@next/font/local',
options: { subsets: ['latin'] },
}, },
], ],
}, },
......
import { Open_Sans } from '@next/font/google' import { Open_Sans } from '@next/font/google'
const openSans = Open_Sans() const openSans = Open_Sans({ subsets: ['latin'] })
export default function Inter() { export default function Inter() {
return <p className={openSans.className}>Hello world</p> return <p className={openSans.className}>Hello world</p>
......
...@@ -5,9 +5,6 @@ module.exports = { ...@@ -5,9 +5,6 @@ module.exports = {
loader: '@next/font/google', loader: '@next/font/google',
options: { subsets: ['latin'] }, options: { subsets: ['latin'] },
}, },
{
loader: '@next/font/local',
},
], ],
}, },
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment