Skip to content

[Bug]: Next. An error occurred in next/font with @fullhuman/postcss-purgecss #1298

@msfreeman982

Description

@msfreeman982

Describe the bug

Creating an optimized production build ...
Failed to compile.

src\app\layout.js
An error occurred in next/font.

TypeError: require(...) is not a function

Configuration:

 '@fullhuman/postcss-purgecss': {
        content: [
            './src/pages/**/*.{js,ts,jsx,tsx,mdx}',
            './src/components/**/*.{js,ts,jsx,tsx,mdx}',
            './src/lib/**/*.{js,ts,jsx,tsx,mdx}',
            './src/app/**/*.{js,ts,jsx,tsx,mdx}'
        ],
        defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
    }

Layout:

import { Inter } from 'next/font/google';

const inter = Inter({ subsets: ['latin'], display: 'swap' });

export default function RootLayout({ children }) {
    return (
        <html lang="en">
            <body className={inter.className}>{children}</body>
        </html>
    );
}

It doesn't work with "@fullhuman/postcss-purgecss": "7.0.1-alpha.0" OR "@fullhuman/postcss-purgecss": "7.0.2"
but work with "@fullhuman/postcss-purgecss": "6.0.0"

To Reproduce

  1. Install Next 14.2.5
  2. Install "@fullhuman/postcss-purgecss": "7.0.1-alpha.0" OR "@fullhuman/postcss-purgecss": "7.0.2"
  3. Use 'next/font/google' in layout
  4. Run build

Expected Behavior

Build should be successful

Environment

OS: Windows
Next: 14.2.5

"@fullhuman/postcss-purgecss": "7.0.1-alpha.0" OR "@fullhuman/postcss-purgecss": "7.0.2"

Add any other context about the problem here

context

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions