Description
Command
build, serve
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
I have an Angular 17 project using .mts
files. It's working perfectly, both with ng build
and ng serve
. It uses the @angular-devkit/build-angular:application
builder. To support a new feature, I needed to swap a file when running the live-reload mode with ng serve
. Following the documentation for fileReplacements
, I added:
"serve": {
"fileReplacements": [
{
"replace": "src/environments/environment.mts",
"with": "src/environments/environment.serve.mts"
}
],
"ssr": false
},
I now get the following error when running ng serve
:
Error: Schema validation failed with the following errors:
Data path "/fileReplacements/0/replace" must match pattern "\.(([cm]?j|t)sx?|json)$".
The regex pattern does not match what builds without replacement are actually using. Regular builds support "\.(([cm]?[jt])sx?|json)$"
. However, the pattern itself is questionable: why even limit the file extensions here? I don't need it right now, but what if I wanted to swap a .wasm
file or any other kind of file? If a regular build works, adding a file replacement rule should never restrict it more.
Minimal Reproduction
Add a file replacement rule targeting an mts
file. Example:
"fileReplacements": [
{
"replace": "src/environments/environment.mts",
"with": "src/environments/environment.serve.mts"
}
],
Run the corresponding command (ng build
, ng serve
)
Exception or Error
Error: Schema validation failed with the following errors:
Data path "/fileReplacements/0/replace" must match pattern "\.(([cm]?j|t)sx?|json)$".
### Your Environment
```text
$ ng version
Node.js version v21.6.1 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/previous-releases/.
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 17.1.3
Node: 21.6.1 (Unsupported)
Package Manager: yarn 4.1.0
OS: linux x64
Angular: 17.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router, ssr
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1701.3
@angular-devkit/build-angular 17.1.3
@angular-devkit/core 17.1.3
@angular-devkit/schematics 17.1.3
@schematics/angular 17.1.3
rxjs 7.8.1
typescript 5.3.3
zone.js 0.14.3
Warning: The current version of Node (21.6.1) is not supported by Angular.
### Anything else relevant?
_No response_