Webpack regex test for .js & .jsx

I am using webpack and wondering if there is a way to define .js or .jsx extensions with test regex?

i.e.

test: /\.jsx?$/ 

Will this work?

+5
source share
1 answer

Yes. test: /.jsx?$/ should be correct. But you also need to set the resolve.extensions parameter to make it work.

 module.exports = { ... resolve: { extensions: ['.js', '.jsx'] } ... } 
+5
source

Source: https://habr.com/ru/post/1263280/


All Articles