Next.js: Integration: Babel

20th August 2020 at 2:19pm

Next.js 中默认就用了 Babel。如果你想配置 Babel,就在项目根目录下建一个 .babelrc。一个典型的启用了绝对路径 import 的 .babelrc 长这个样子:

{
  "presets": [
    "next/babel"
  ],
  "plugins": [
    [
      "module-resolver",
      {
        "root": ".",
        "alias": {
          "pages": "./pages",
          "components": "./components",
          "interfaces": "./interfaces"
        }
      }
    ]
  ]
}

Resources

See Also