I'm using webpack and wondering if there is a way to determine .js or .jsx file extensions with the test regex?
i.e.
test: /\.jsx?$/
Would this work?
Yes. test: /.jsx?$/
should be the right way. But you also need to set resolve.extensions
parameter to make it work.
module.exports = {
...
resolve: {
extensions: ['.js', '.jsx']
}
...
}
i know this is very old question but i had like to share my solution.
solved it like this
test: /\.(js|mjs|jsx|ts|tsx)$/,
so, .js & .jsx or ts, tsx and mjs
these all extensions are going to be match. Much more elegant. May it help someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With