modify-source-webpack-plugin
modify-source-webpack-plugin copied to clipboard
Give access to full file path in the modify callback
Hey there!
It would be great if you could add an option to pass the full path instead just the basename
as value for the filename argument in the modify callback.
WDYT? :)
Hi man.
It's a good idea, I think we can add new argument path
and leave filename
as exists. It's will be more handy, because you will don't need to pass an extra option.
module.exports = {
plugins: [
new ModifySourcePlugin({
rules: [
{
test: /my-file\.js$/,
modify: (src, filename, path) => src + `...`
}
]
})
]
};
What do you think?
If it was my lib then I'd replace the filename
with path
and simply bump to a new major version to signal breaking API changes.
Because having both path
AND filename
is unnecessary as one can be derived easily from the other.
But I'd be absolutely fine with going the route of adding a third argument as well, since from a usage perspective it does not make a big difference 👍 :)
Yeah it's a better idea. And bumping new major version it's a good point. I just don't know how to deal with version for webpack 4 because we have two versions - 1.1.0-beta.3
for webpack 4 and 2.0.0-beta.7
for webpack 5. If we planned to support two versions we should update 1.1.0-beta.3
too and it's will be failed semver (already, lol).
Probably we can move support for webpack 4 and webpack 5 in a single version (3.0.0
, for example). But there was a problem why I changed to 2 separated versions - we cannot hold two webpack versions in one package.json
. So tests also will be only for one version. And working TypeScript types too.
I'm ready to ship this breaking improvement if we will solve this issue with versions. Let me know if you have ideas, it's will be great help for this project 😉👍
@epegzz Should be fixed in #55. You can test before it's got released by installing modify-source-webpack-plugin@next
. Version 3.0.0-rc.0
.
Now we will have single version of plugin for webpack 5 and 4 🥳
Thank you!! Works like a charm 👏 😃