-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any posibility to run this with watch mode? #6
Comments
Thanks! This plugin is assuming that there probably isn't any physical file to watch - so I'm not sure we should try to add the functionality here. It should probably be an additional plugin that adds additional files to the watcher. Take a look at Webpack's bundled WatchIgnorePlugin. I think you could pretty easily copy that and reverse the functionality so the paths passed to the plugin are merged in. If you get that working, please update this issue with a link to your repository or a gist so others that might need it can find it from here. I could update the README here with a link to it and example as well. |
Hi, we're having the same issue. |
@FrancescoCioria Thanks for giving feedback. I was suggesting to create a new plugin - maybe called But I see what you're saying. That would get webpack to rebuild on change of your additional files, but it wouldn't update the virtual module contents as those are currently only fetched when the webpack config is created. We'd need to create some type of watch/dev mode that would have it re-fetch the contents every time within the resolvePlugin. That dev option would also pass through to the populateFilesystem function so it would allow overwriting the existing contents - currently prevented here. It would probably be required to pass in the contents as a function in that case. Unfortunately, I probably won't have bandwidth any time soon to work on that. But I would take a pull request - especially one that adds additional test coverage for the new functionality. Thanks. |
You don't need to lean on file system watches as surfaced through the Look at how the Essentially, you'll want to clone it - but replace its Probably by expanding the function-type signature for const VirtualModulePlugin = require('virtual-module-webpack-plugin');
module.exports = {
entry: './index',
plugins: [
new VirtualModulePlugin({
moduleName: './time-of-day.txt',
contents(invalidate) {
setTimeout(invalidate, 10e3);
return `export default "The time is: ${Date()};"`;
}
})
]
}; Another thing you could try is to -- rather than inject files into the existing Then implement watches on your virtual file system and a means to propagate them from both the original and virtual one on the merging file system. |
Great job, This plugin works great, and I really like it.
I'm stuck in making this plugin works with watch mode.
The use case is:
Now we want to run watcher when source file is changed:
this should trigger:
Any advice will be helpfull, the case is not so standard, we use multiple source files like templates then build it inside webpack file like:
The problem is that
public/elements/[some-element].js
is not under webpack scope (no entry points)The text was updated successfully, but these errors were encountered: