Make babel exclude test files

前端 未结 2 483
日久生厌
日久生厌 2021-02-03 17:00

On my build step I\'m using babel to transpile the code to es5 (from src to dist). How do I make it exclude files ending in .test.js?

相关标签:
2条回答
  • 2021-02-03 17:30

    As of today, the following works in .babelrc (babel-core: v6.26.3)

    "ignore": [
      "**/__tests__", // ignore the whole test directory
      "**/*.test.js" // ignore test files only
    ]
    
    0 讨论(0)
  • 2021-02-03 17:47

    Based on the documentation, you should be able to write .babelrc

    {
      "ignore": [
        "**/*.test.js"
      ]
    }
    

    However, I was able to verify that this does not seem to work. I tried it with version 6.5.1 (babel-core 6.5.2).

    At the same time, the following does work:

    babel src --out-dir build --ignore '**/*.test.js'
    

    That is the same glob pattern as written in the .babelrc file. If you install any glob library from npm you'll find that this glob pattern would work (that is how I came up with it...I do not currently use babel).

    0 讨论(0)
提交回复
热议问题