【问题标题】:Make Nextjs to ignore babel.config.js让 Nextjs 忽略 babel.config.js
【发布时间】:2020-07-11 23:43:24
【问题描述】:

我有一个 nextjs 应用程序,我希望 babel 自定义运行 jest 套件进行测试,但是当我配置 babel.config.js 文件时 jest 运行成功,但 nextjs 也采用了我不想要的配置,我希望 nextjs忽略 babel.config.js,我该怎么做?

【问题讨论】:

  • 我希望 nextjs 有 nextjs 附带的默认 babel 配置

标签: reactjs jestjs babeljs next.js


【解决方案1】:

只需为测试创建一个不同的文件名(如babel.config.test.js)并开玩笑使用它。

我假设你在 package.json 里面的玩笑配置

// package.json

{
  "jest": {
    "transform": {
      "\\.js$": ["babel-jest", { "configFile": "./babel.config.test.js" }]
    }
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-17
    • 2013-10-11
    • 2021-05-22
    • 1970-01-01
    • 1970-01-01
    • 2014-11-12
    • 2013-04-19
    • 2010-11-27
    相关资源
    最近更新 更多