-
Notifications
You must be signed in to change notification settings - Fork 12k
html file replacement doesn't work #14599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am having the same exact issue but only appears to surface when targeting es2015 in the tsconfig.json file. If I target es5 the html file replacement works just fine. |
Hi, this is because the index file for builds is outside of the webpack compilation. To change the index file, instead of |
but it worked on Angular 7, why you had to change it? |
This is not a feasible solution as leveraging the --index argument does not rename the specified file the same way that file replacements does. This feature was working fine in older versions of webpack. As far as I can see this is a breaking change. Why was this issue closed without further review? |
@alan-agius4 This really should have been mentioned as a breaking change in the release information |
@alan-agius4 Can you explain why you have closed this? Using index is not a like for like option. |
The file replacements option was never intended to replace files outside of the script bundles. That it worked previously was more of a defect itself than anything else. |
@clydin then it should be more documented because fileReplacements documentation does not impose any restrictions on the file type |
The type actually isn't the relevant aspect. Only bundled files are affected by the option. HTML files used as templates are intended to work, for instance. |
I just finished all changes on my projects to move to Angular 8. If I cannot deliver the new features of my applications right now ! One twicky solution:
However I want to use |
eventually
did the trick for me but I think it's kinda ugly |
For information, when serving the application:
instead of building it only:
Then file replacements on index.html is done correctly. The difference between the dev environment and the production environment can be quite confusing. |
Updated to Angular 8, production builds not working ... scratching my head :) |
It seems like this is impacting a good number of people and we haven't seen any viable solutions to this problem yet. Can we please re-open this issue? |
A solution that worked for me: Create a folder called
with subfolders for each index page you have and update your package.json like so:
This will replace your index.html with the one in the folder |
even .ts not worked for me
it prints the console.log of index.ts not dev.ts |
#10992 would make one assume that |
It's always been that case. It just so happened that it unintentionally worked for the index.html in several previous versions. The |
@clydin unintentional or not, this was the official answer when the feature was asked for. Also @alan-agius4 as far as I know we're not on a dictatorship, throwing your answer and closing the issue without even letting the OP, or others that need the feature, answer. This change broke a lot of builds. |
It would be nice if the documentation was updated with this feature, and if someone could provide an example. |
Yes, the docs on |
Had to use @boban984 answer to make it work. If you just let the index.prod.html in the root folder, and use it with --index, it will not be renamed properly... Don't get it, was working fine before and just realized today that our prod file was not the expected one 😫🤬Not cool |
Example of #15010 configuration: "architect":{
"build": {
"options": {
"index": "src/index.html", //non-prod
},
"configurations": {
"production":{
"index": { //prod index replacement
"input": "src/index.prod.html",
"output": "index.html
}
}
}
} |
I almost pushed our app to production with wrong index.html :( @Nodarii answer works after deleting $schema -property (which is not nice) from angular.json. Schema seems outdated because it says that index should be a string. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
Command (mark with an
x
)Description
After upgrading to Angular 8 file replacement stopped working for html files.
🔬 Minimal Reproduction
https://github.com/diogen737/fileReplacement-test
Expexted behavior
since there's html replacement config in
angular.json
afterng build --prod
I expect to see"this is prod index" on top of the page (localhost:8080/tester) which is present in
index.prod.html
and absent inindex.html
from which I conclude that html filre replacement is not working anymore.🌍 Your Environment
The text was updated successfully, but these errors were encountered: