filemanager-webpack-plugin
filemanager-webpack-plugin copied to clipboard
replace in file
Hi,
Could you please consider to implent a 'replace in file' action, that would be great.
Thanks :)
Seconding this. I use ReplaceInFileWebpackPlugin today, but I can't get it to execute before the FileManagerPlugin starts
Seconding this. I use ReplaceInFileWebpackPlugin today, but I can't get it to execute before the FileManagerPlugin starts
Saw the plugin, FMP uses afterEmit hook
and ReplaceInFileWebpackPlugin used done hook
. afterEmit executes before done hook. so it is not possible.
Also I am not so sure about replacing in file, since this happens before and after the compilation. Problem with that is If we are replacing the content of the emitted file after compilation, it will change the contenthash of the files, will then need to find and replace in all of its related assets.
Thanks for the reply, I understand. Then it seems that there is no real solution if you want to zip the dist after changing some values in it.
Do you think it could be possible to add a wait timer, as a workaround? Or a kind of "beforeHook" that would let the user run some logic before executing the onEnd events (which in my case could let me tell the script to sleep for 1s for instance)
Do you think it could be possible to add a wait timer, as a workaround? Or a kind of "beforeHook" that would let the user run some logic before executing the onEnd events (which in my case could let me tell the script to sleep for 1s for instance)
Not sure. can you post what you are trying to achieve?
Also I saw the processassets hook in webpack-5, about letting users specify the stage and callback with assets. I am not sure that will help. but I haven't got enough time to evaluate the options.
I have a few config file in my app with placeholder values, and I use ReplaceInFileWebpackPlugin
to replace these placeholders with their actual values.
Then I want to zip my whole dist
folder. With the current timing of the operations though, the FileManager kicks in before the replace file process can complete, and so I still have the placeholders in my final zip.
So it's really an operation that I want to perform once the full build process is over.
got it. may be if you are using webpack 5 you could use this plugin copy-asset-in-memory-webpack-plugin and tap into a specific stage to do the transform/replace on the code, or use copy-webpack-plugin which also has a transform function (I am not sure that will help your case) Meanwhile I'll see what I can do here.
Could you add some additional compiler hooks such as onDone
, afterDone
etc? This should make it possible to attach the plugin to different phases and resolve the issue.