跳到主要內容
設定next.config.jsoptimizePackageImports

optimizePackageImports

有些套件可能會匯出數百甚至數千個模組,這可能會在開發和生產環境中造成效能問題。

將套件新增至 experimental.optimizePackageImports 將只載入您實際使用的模組,同時仍讓您方便地編寫具有多個具名匯出的 import 陳述式。

next.config.js
module.exports = {
  experimental: {
    optimizePackageImports: ['package-name'],
  },
}

以下程式庫預設為最佳化

  • lucide-react
  • date-fns
  • lodash-es
  • ramda
  • antd
  • react-bootstrap
  • ahooks
  • @ant-design/icons
  • @headlessui/react
  • @headlessui-float/react
  • @heroicons/react/20/solid
  • @heroicons/react/24/solid
  • @heroicons/react/24/outline
  • @visx/visx
  • @tremor/react
  • rxjs
  • @mui/material
  • @mui/icons-material
  • recharts
  • react-use
  • @material-ui/core
  • @material-ui/icons
  • @tabler/icons-react
  • mui-core
  • react-icons/*