webpack-bundle
webpack-bundle copied to clipboard
Recompile manifest in cache dir
Everytime i clear the symfony cache, manifest is deleted and i have to recompile to generate another manifest. There is a solution to handle this? Like use symfony cache warmer, or a specific config for this problem?
This is a fairly important issue that needs to be fixed. A cache clear shouldn't cause the application to break, which is what happens in this instance. It also causes problems when generating assets during build process as the webpack_manifest.php
file is missing when deployed.
Just discovered that you can configure the manifest file path which solves the cache clear issue.
maba_webpack:
config:
manifest_file_path: '%kernel.cache_dir%/webpack_manifest.php'
When running maba:webpack:dev-server
in the background, command automatically resets dev-server
executable in this case, so assets get recompiled and manifest file dumped. On the other hand, it takes some time, so it's not really great DX. Just for the reference, what's your use case of clearing the cache manually in development? Is this needed quite often?
Of course, if using maba:webpack:compile
, this must be re-run after clearing the cache.
Cache warmer was not initially implemented as dev-server
is recommended approach when working on assets. Cache warmer would mean that there would be additional work being done (by both dev-server
and cache warmer) and race conditions might occur (as dev-server
generates different URLs than compile command or cache warmer would). This would mean that it should be executed conditionally, based on configuration, which would make it even more difficult to use.
During build process, maba:webpack:compile --env=prod
must be ran after clearing the cache - I'll clarify this in readme.