Skip to content
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

Improve assets precompilation #326

Open
olivierobert opened this issue Mar 18, 2022 · 5 comments
Open

Improve assets precompilation #326

olivierobert opened this issue Mar 18, 2022 · 5 comments

Comments

@olivierobert
Copy link
Contributor

Why

The template has a workaround to precompile assets for the production env. Since Rails seems to require all env variable to be set, the following add a dummy value:

if rails_env == 'production'
env_keys = YAML.load_file('config/application.yml')['docker_build'].keys
env_keys.each { |name| ENV[name] = 'dummy_value' }
end
exit system('bin/rails i18n:js:export && bin/rails assets:precompile')

However, with the new build process with esbuild, it seems that just setting the env variable ASSET_ENV=production is sufficient as per this article. So it might be time to revisit.

Also, it would be good to sync assets files to S3 as well instead of serving assets from Heroku.

Who Benefits?

Web developers who work on Ruby on Rails projects

@rosle rosle added this to the 5.1.0 milestone Mar 18, 2022
@rosle rosle removed their assignment Mar 21, 2022
@malparty malparty modified the milestones: 5.1.0, 5.2.0 Jul 15, 2022
@malparty
Copy link
Member

@hoangmirs @andyduong1920 anyone willing to work on this one? :D
If this one was implemented, we would not have spent time debugging the missing adapter issue (from #191 #264 )

Thanks!! 🙇

@andyduong1920
Copy link
Member

Hi @malparty, I'm not sure this is related to the #264 issue :D

I didn't catch up with the Rails assets tooling for a while; before starting this improvement, are we using esbuild as the default tool for modification?

Also, will we target to sync the compiled assets to S3 on the same issue 🤔 should we separate that into two different topics 🤔

@malparty
Copy link
Member

@andyduong1920
These are 2 different issues indeed— they can be done independently I think 🤔 (starting with the assets pipeline improvement first, then configuring S3 later)

@andyduong1920
Copy link
Member

Also @malparty FYI we might improve the asset pipeline but for the rake task like bin/rails i18n:js:export it's still required all ENV 😂 because that is the Rails way FYI

@malparty
Copy link
Member

Yep, maybe we should use the NPM i18n package for running the export command... It might be more performance as well 😇 but this is at risk to duplicate the configuration for exporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants