Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does the :8 mean in Webpack's output variables. filename: [name][contenthash:8]?

I’m configuring Webpacks output and i have run into some examples which have this unusual
syntax added on the end.

output: {
    filename: '[name][fullHash:8].bundle.js',
    chunkFilename: '[name][fullHash:8].bundle.js',
    path: `${__dirname}/dist`,
    publicPath: "/",
},

Ok now you see the :8’s after fullhash? what extra feature does it provide? My first guess was UTF-8??? But that’s just a stab in the dark.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

So from a quick little search in the docs, I found this one section which talks about it

The length of hashes ([hash], [contenthash] or [chunkhash]) can be specified using [hash:16] (defaults to 20). Alternatively, specify output.hashDigestLength to configure the length globally.

So going by that, it would probably mean that [fullHash:8] would produce a hash of length 8, which I suppose I would advice against, and would be better off to keep it at the default of 20 (by just removing the :8).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading