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

Extend transformFn #23

Closed talkshowhost closed 6 years ago

talkshowhost commented 6 years ago

Is it possible to expand the transformFn with further customization?

For example, I would like to return every file that ends in .module.js.

This way I can have a module under users in a folder called form whereas the module filename would be users.form.module.js. This way I could include in users.module.js something like this

import usersFormModule from './form';

The way it is now, I can only do it with index file or pointing exactly to the filename. Having the name of the module being form.module.js would defeat the purpose if I have a form on another folder and the filename would have to be the same.

shaketbaby commented 6 years ago

Yes, will need to know the full path to do what you described, think I can pass the full path and the original resolving request to transformFn in addition to just basename as it is now.

shaketbaby commented 6 years ago

I've created a PR #24 , would you please be able to confirm that it meets your requirement?

talkshowhost commented 6 years ago

Many thanks for the quick reply!

I think it will.

At least that's all the info I imagine we can have on that function. The other solution I can imagine is returning an extension (as in .module.js) or a regex but I believe that would be a bit more complicated.

shaketbaby commented 6 years ago

Cool, I have released a new version 2.3.0.