I am trying to rename a file during the assets copy of ng build
Here is what I have used in angular.json
:
"outputPath": "dist",
"assets": [
...,
{
"glob": "favicon-v1.png",
"input": "src/client",
"output": "/favicon.png"
},
...,
],
Instead of creating file dist/favicon.png
, ng build
is creating a dist/favicon.png/favicon-v1.png
.
It seems to refuse to rename the file - it always creates a folder with the name I wanted to use favicon.png
and then puts the original file inside it.
Is it expected behavior? Any workaround other than renaming the file favicon-v1.png
to favicong.png
in the source control?
I am using:
"@angular/cli": "^6.1.5"
"@angular/animations": "^6.0.1",
"@angular/common": "^6.0.1",
"@angular/compiler": "^6.0.1",
"@angular/core": "^6.0.1",
"@angular/forms": "^6.0.1",
"@angular/http": "^6.0.1",
"@angular/platform-browser": "^6.0.1",
"@angular/platform-browser-dynamic": "^6.0.1",
"@angular/router": "^6.0.1",
"@angular/upgrade": "^6.0.1",
Update: Similar code works fine with angular-cli.json in Angular 5.
You cannot rename the file like this since input and output properties are folders. Look at the documentation here. I don't know why exactly you need that but you could for example put the v1 icon in a v1 subfolder with already the final name and then you can use the asset setting to copy from the v1 folder to the output when you need the v1 icon. Else you can always use a custom library or a custom script to do it and remove it from the assets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With