Skip to content

Commit

Permalink
Use a more appropriate regexp for removing hash from a filename (#4510)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
fatfisz authored and timneutkens committed Jun 7, 2018
1 parent 631e6c7 commit e6ff476
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/utils.js
Original file line number Diff line number Diff line change
@@ -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
}
})

0 comments on commit e6ff476

Please sign in to comment.