Search code examples
javascriptregexwebpackrequire

Webpack require files from specific sub-directories


Here's my folder structure

- componentA
  - specs
     - file1.js
     - file2.js
 - componentB
  - specs
     - file1.js
     - file2.js

I want to require each file under each specs dir from both componentA and B. How would the regex look like?

something like: require(**/specs/*.js) ?


Solution

  • So this fixed it for me:

    /.*\/specs\/.*\.js/