Razzle: Use contenthash instead of hash

Created on 12 Jun 2020  路  2Comments  路  Source: jaredpalmer/razzle

馃殌 Feature request: [contenthash] instead of [hash]

I think it should be possible to change the [hash:8] in file-loader to use [contenthash:8] which should mean that if you don't make changes to a file it wouldn't get a new hash when you rebuild.

https://github.com/jaredpalmer/razzle/blob/master/packages/razzle/config/createConfig.js#L159

Current Behavior

Using [hash:8] would mean a per-build hash is used on the file so every build/deploy would invalidate the cache those media resources.

Desired Behavior

Using [contenthash:8] should make it a stable filename across builds as long as the content of the file doesn't change, meaning you can have longer lived caching on static files.

Additional context

My initial thought was that this could also be applied to url-loader as well https://github.com/jaredpalmer/razzle/blob/master/packages/razzle/config/createConfig.js#L171

But I'm a bit confused at the config here because it seems like it's passing options to url-loader that it doesn't support. emitFile and name don't seem to be valid options https://webpack.js.org/loaders/url-loader/

Should url-loader be specifying a fallback to file-loader instead? I'm not exactly sure without spending more time investigating

enhancement webpack-config

Most helpful comment

fixed in dev

All 2 comments

I鈥檓 not quite sure about this either. Did url loader change maybe? I need to investigate too. 馃

fixed in dev

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebmor picture sebmor  路  4Comments

alexjoyner picture alexjoyner  路  3Comments

MaxGoh picture MaxGoh  路  4Comments

dizzyn picture dizzyn  路  3Comments

gabimor picture gabimor  路  3Comments