shaketbaby / directory-named-webpack-plugin

A Webpack plugin that treats a file with the name of directory as the index file
MIT License
182 stars 17 forks source link

".jsx" extension instead of ".js" #32

Closed iagobruno closed 6 years ago

iagobruno commented 6 years ago

How do I make the plugin also look for a ".jsx" file if there is no "js" file?

Example:

// Folder structure
components
├── Header
│   ├── Header.css
│   └── Header.jsx
├── Footer
│   └── Footer.jsx
└── ...
// Footer/Footer.jsx
import Header from '../Header'

I'm trying to use the "transformFn" option but to no avail. Can you help me?

shaketbaby commented 6 years ago

Need to tell Webpack to look for that extension. In the resolve settings, add jsx to extensions array

module.exports = {
  //...
  resolve: {
    extensions: ['.wasm', '.mjs', '.js', '.json', '.jsx']
  }
};
iagobruno commented 6 years ago

Thanks man!