'Can I Get Next.Js to exclude .babelrc during build?

I'd like to not include .babelrc during build since SWC is disabled as a replacement for Babel. I only need .babelrc for a plugin for dev testing purposes that is not supported by SWC yet. I am told to check the doc about ignored compiler options but the page is down, and I could not find a solution from the nextjs document on disabling SWC and its feedback thread.

Disabling SWC as replacement for Babel Ignored Compiler Options Next.js page down



Solution 1:[1]

Super hacky, but you could modify the build script in package.json to temporarily rename the config file before the build then restore it after:

{

  "scripts": {
    "dev": "next dev",
    "build": "mv .babelrc .babel_ && next build; mv .babel_ .babelrc",
    "start": "next start",
    "lint": "next lint"
  }

}

It's not a cross-platform solution, however.

Solution 2:[2]

I think you can add .babelrc to .gitignore, and it won't be used during build.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark G
Solution 2