From e6ff476198dba8535049c2a6ed6e6ce47ede97f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ruci=C5=84ski?= Date: Thu, 7 Jun 2018 13:19:53 +0200 Subject: [PATCH] Use a more appropriate regexp for removing hash from a filename (#4510) Fixes one of the problems described in #4433. The old regexp was removing everything after a hyphen, so with a chunk name like so: ``` chunks/path-to-a-file-[hash].js ``` the saved chunk name was ``` chunks/path ``` This caused problems, because webpack by default changes `/` to `-` in chunk names generated e.g. by ``import(`foo/${bar}`)``. After this change the chunk name will be ``` chunks/path-to-a-file ``` --- server/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/utils.js b/server/utils.js index a233aeb8..03139953 100644 --- a/server/utils.js +++ b/server/utils.js @@ -13,7 +13,7 @@ export function getAvailableChunks (distDir) { chunkFiles.forEach(filename => { if (/\.js$/.test(filename)) { - const chunkName = filename.replace(/-.*/, '') + const chunkName = filename.replace(/-[^-]*/, '') chunksMap[chunkName] = filename } })