1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

Improve asset versioning task

Improved logic for replacing the value to allow for simpler regular expression patterns. Lookbehinds and lookaheads are no longer required.
This commit is contained in:
Chauncey McAskill
2023-01-13 16:42:47 -05:00
parent b6970832a3
commit 3cd81bdb3e
2 changed files with 20 additions and 3 deletions

View File

@@ -387,7 +387,7 @@ The regular expression can be a `RegExp` object or a pattern prefixed with `rege
* ```json
{
"key": "regexp:(?<=^const ASSETS_VERSION = ')(?<version>\\d+)(?=';$)"
"key": "regexp:(?<=^const ASSETS_VERSION = ')(?<build>\\d+)(?=';$)"
}
```
@@ -398,10 +398,14 @@ The regular expression can be a `RegExp` object or a pattern prefixed with `rege
```
* ```js
{
key: /(?<=\bconst ASSETS_VERSION = )[^;]+/
key: /^ \* Version: +(?:.+?)\+(.+?)$/
}
```
The regular expression pattern will match the first occurrence and replace
the first match in the following order: `build` (named capture), `version`
(named capture), `1` (first capture), or `0` (whole match).
See [`versions.js`](../build/tasks/versions.js) for details.
[Autoprefixer]: https://npmjs.com/package/autoprefixer