benjii66 / Portfolino

le portfolio next.js
0 stars 0 forks source link

conflict between Babel and NextJS #2

Open benjii66 opened 7 months ago

benjii66 commented 7 months ago

[!WARNING] I couldn't run my dev environment anymore because of the SWC compiler and Babel used 'next/font'. The issue came from >that I haven't well setted up my Babel config.

my terminal returned this :

Syntax error: "next/font" requires SWC although Babel is being used due to a custom babel config being present. Read more: https://nextjs.org/docs/messages/babel-font-loader-conflict

benjii66 commented 7 months ago

[!TIP] The solution was to force babel to run only in the test environment :

module.exports = function(api) {
  api.cache(true); //that's for the Babel's cache possible issue

  const isTest = api.env('test');  //for the test environment

  if (isTest) {
    return {
      presets: [
       yourpresets
      ],
    };
  }

  return {};
};