Next.js Discord

Discord Forum

How do configure optimizePackageImports?

Unanswered
Black-tailed Godwit posted this in #help-forum
Open in Discord
Black-tailed GodwitOP
Post Instructions: https://nextjs.org/docs/app/api-reference/next-config-js/optimizePackageImports
PR Instructions: https://github.com/vercel/next.js/pull/54572

For example react-icons library?

just need to do this?:

/** @type {import('next').NextConfig} */
const nextConfig = {
    optimizePackageImports: ['react-icons'],
}



or

import { HiPaperClip } from "react-icons/hi2";


to

import { HiPaperClip } from '__barrel_optimize__?names=HiPaperClip!=!react-icons/hi2?__barrel_optimize_noop__=HiPaperClip'


and then:

/** @type {import('next').NextConfig} */
const nextConfig = {
    optimizePackageImports: ['HiPaperClip'],
}

1 Reply