1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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
```
This commit is contained in:
Rafał Ruciński 2018-06-07 13:19:53 +02:00 committed by Tim Neutkens
parent 631e6c7eba
commit e6ff476198

View file

@ -13,7 +13,7 @@ export function getAvailableChunks (distDir) {
chunkFiles.forEach(filename => { chunkFiles.forEach(filename => {
if (/\.js$/.test(filename)) { if (/\.js$/.test(filename)) {
const chunkName = filename.replace(/-.*/, '') const chunkName = filename.replace(/-[^-]*/, '')
chunksMap[chunkName] = filename chunksMap[chunkName] = filename
} }
}) })