WebPack中的输出变量是什么意思。文件名:[name] [contenthash:8]?

发布于 2025-02-08 06:51:05 字数 298 浏览 1 评论 0原文

我正在配置WebPacks输出,并且遇到了一些具有这种不寻常的示例 末尾添加了语法。

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

好的,现在您看到全哈之后的8点?它提供什么额外功能?我的第一个猜测是UTF-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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁〃客ぐ 2025-02-15 06:51:05

因此,从

可以使用[hash:16](默认为20)指定哈希长度([hash],[contenthash]或[chunkhash])。另外,指定输出。hashDigestLength以在全球上配置长度。

因此,这样做可能意味着[fullhash:8]将产生长度8的哈希,我想我会建议反对,并且最好将其保留在默认情况下20(通过删除:8)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文