Skip to content

feature request: single assets in i18n builds #26286

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

Open
zip-fa opened this issue Nov 8, 2023 · 14 comments
Open

feature request: single assets in i18n builds #26286

zip-fa opened this issue Nov 8, 2023 · 14 comments
Labels
devkit/build-angular:i18n feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature

Comments

@zip-fa
Copy link

zip-fa commented Nov 8, 2023

Command

build

Description

Hi.
Currently angular just copy assets folder to every localized build. This leads to enormous dist size (in my case every locale with assets weigths 180MB, which can be multiplied by 15 locales).

Describe the solution you'd like

My proposal is to put assets folder in root directory, instead of copying it inside every built locale, and symlink it inside every locale. This will give us better build times, and also will fix issues where developers use absolute urls to assets, eg:

<img src=“/assets/img.png” />

My solution will give developers a way to use localized builds in mobile apps development (with capacitor for example; for now it’s strange to publish mobile app which weights over 2gb), better build times (no need to copy assets to every locale), better deploy times (transfer 180mb instead of 2.7GB)

Describe alternatives you've considered

Currently, the only issue i encounter, is absolute path usage (described it in my example with img src). I make symlink to get this working:

/en/assets -> /assets

@zip-fa zip-fa changed the title feature request: make symlinks to assets in i18n builds instead of copying 🌐 feature request: make symlinks to assets in i18n builds instead of copying Nov 8, 2023
@dgp1130 dgp1130 added the needs: discussion On the agenda for team meeting to determine next steps label Nov 8, 2023
@zip-fa
Copy link
Author

zip-fa commented Nov 13, 2023

A little update:

I just took two different localized builds and compared their hashTables from ngsw.json. Their assets' hashes are totally identical when using application builder, so i can assume, this feature can be done without pain.

@alan-agius4 alan-agius4 changed the title 🌐 feature request: make symlinks to assets in i18n builds instead of copying feature request: make symlinks to assets in i18n builds instead of copying Nov 22, 2023
@zip-fa
Copy link
Author

zip-fa commented Dec 4, 2023

Hi guys. I see “Needs discussion” badge was added, what does it mean? Will this be done?

@alan-agius4
Copy link
Collaborator

needs: discussion means that this issue needs to be discussed further with the rest of the team.

We already discussed this during one of our team meetings but we haven't reached a definitive conclusion on the next steps. However, we reached a consensus that if an action is taken, it's improbable that it will involve a symlink-based approach.

@dgp1130
Copy link
Collaborator

dgp1130 commented Jan 3, 2024

Spent some time discussing this in the team today. Our immediate reaction is that symlinks in the output might cause some issues for servers. In my experience, servers are typically hesitant to follow symlinks as they can often be the result of a misconfiguration issue and accidentally serve data which wasn't intended to be served. In this case, such symlinks would be internal to the served directory and (probably) safe, but I could see some servers getting this wrong or requiring explicitly enabling symlinks which server admins might not want to do.

An alternative proposal which might be better is to just emit an assets/ directory independently of the locale. That way there is only one copy of the assets. This has the additional benefit that there is only one URL for each asset. This way if a user downloads /assets/foo.png and then switches locale and re-requests /assets/foo.png, the URL is consistent and the browser cache can respond more quickly. This would also mean absolute paths can be used for requesting assets without having to manually include the locale.

This would definitely be a breaking change for existing applications, so I don't think we can automatically make this change, it would need to be behind a flag. Not sure what the naming for this flag would be, but under i18n options we could include something like singleAssetDir: true to enable this behavior. I do like this approach in general, and if it works out in practice we might want to consider enabling it by default for new applications, even if we don't necessarily have a path to automatically migrating existing apps.

@dgp1130 dgp1130 added feature Issue that requests a new feature devkit/build-angular:i18n and removed needs: discussion On the agenda for team meeting to determine next steps labels Jan 3, 2024
@zip-fa
Copy link
Author

zip-fa commented Jan 3, 2024

This sounds like a good solution. I dont think there are many people who use i18n + ssr now, so it won’t break many apps. Maybe make this approach as default and add option like { cloneAssetsForEachLocale: boolean } (which is false by default)?

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Jan 4, 2024
Copy link
Contributor

angular-robot bot commented Jan 4, 2024

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

@alan-agius4 alan-agius4 changed the title feature request: make symlinks to assets in i18n builds instead of copying feature request: single assets in i18n builds Jan 11, 2024
@demurgos
Copy link
Contributor

This feature would not only reduce build sizes considerably and improve caching, it also enables to output static files outside of the locale directories (favicon.ico, robots.txt, .well-known, etc.).

@spock123
Copy link

spock123 commented Jan 22, 2024

I wish I could upvote this a million times.
We have an application with a gazillion locales. For deployment we copy a local assets folder into the root folder of the dist folder, then recursively delete all the "locale" assets folders. But it's quite messy . Having a "non locale sensitive" assets would be really useful

Copy link
Contributor

angular-robot bot commented Feb 13, 2024

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

This comment was marked as outdated.

@angular-robot angular-robot bot added feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors and removed feature: votes required Feature request which is currently still in the voting phase labels Mar 3, 2024
@clydin clydin added feature: under consideration Feature request for which voting has completed and the request is now under consideration and removed feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors labels Jul 10, 2024
@martinboue
Copy link

@dgp1130, have you also considered not copying the global style files to each locale? Those defined in projects > myapp > architect > build > options > styles.

Is there any use case where they can be different depending on the locale? Thanks.

@dabbabi
Copy link

dabbabi commented Sep 25, 2024

Hi, is there any chance to reconsider this vote, please? This is vital for new applications and especially containerised ones. I totally agree with @spock123 to upvote it more than one million time. By the way, what is the minimum requirement vote to push it back to the backlog?

@bhayward93
Copy link

I definitely think that this is something that should be considered again.

@y-reut
Copy link

y-reut commented May 7, 2025

This is still bad DX managing files like robots.txt. It would be nice to have a way to create a single folder for assets out of locales folders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devkit/build-angular:i18n feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

10 participants