You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run rails assets:precompile w/SHAKAPACKER_ASSET_HOST=host-a
Run rails assets:precompile w/SHAKAPACKER_ASSET_HOST=host-b
I would expect that any assets that depended on the asset host would be recompiled the second time and I would now have two different copies of assets w/different fingerprints.
For example, if my application.js includes paths to assets that change when the asset host changes, I would expect to end up with application-hash1.js and application-hash2.js in my output directory.
We do this internally so that we can include a precompiled version of both our production and our staging assets inside of our docker containers, and we serve those assets from different subdomains.
Actual behavior:
On the first call to rails assets:precompile assets are compiled. On the second call, I get this message:
DEBUG -- : Everything's up-to-date. Nothing to do
This appears to be because shakapacker's DigestStrategy only takes the digest of the asset and the name of the environment into account when deciding if an asset is stale.
More context:
We have been able to monkeypatch our way around this internally by doing something like this:
moduleShakapackerclassImprovedDigestStrategy < DigestStrategyprivatedefcompilation_digest_path# The default DigestStrategy stores the digests in a single file per environment. Instead, we# want to store a separate digest for each combo of environment and asset host## To do this, we construct a string containing the values of the env vars we care about and# append their hash to the filename.key=[Rails.application.config.asset_host,ENV['SHAKAPACKER_ASSET_HOST']].join('-')hash=Digest::SHA1.hexdigest(key)config.cache_path.join("last-compilation-digest-#{Shakapacker.env}-#{hash}")endendclassCompilerStrategyclass << selfalias_method:original_from_config,:from_configdeffrom_configifShakapacker.config.compiler_strategy == 'digest_improved'Shakapacker::ImprovedDigestStrategy.newelseoriginal_from_configendendendendend
Expected behavior:
rails assets:precompile
w/SHAKAPACKER_ASSET_HOST=host-a
rails assets:precompile
w/SHAKAPACKER_ASSET_HOST=host-b
I would expect that any assets that depended on the asset host would be recompiled the second time and I would now have two different copies of assets w/different fingerprints.
For example, if my
application.js
includes paths to assets that change when the asset host changes, I would expect to end up withapplication-hash1.js
andapplication-hash2.js
in my output directory.We do this internally so that we can include a precompiled version of both our production and our staging assets inside of our docker containers, and we serve those assets from different subdomains.
Actual behavior:
On the first call to
rails assets:precompile
assets are compiled. On the second call, I get this message:This appears to be because shakapacker's
DigestStrategy
only takes the digest of the asset and the name of the environment into account when deciding if an asset is stale.More context:
We have been able to monkeypatch our way around this internally by doing something like this:
And then in
shakapacker.yml
:Setup environment:
The text was updated successfully, but these errors were encountered: