How do configure optimizePackageImports?
Unanswered
Black-tailed Godwit posted this in #help-forum
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?:
or
to
and then:
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
@Black-tailed Godwit 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'],
}
you don't need to implement this youself as: https://github.com/vercel/next.js/pull/55572 (just wait for next canary version or stable)