Skip to content

Avoid running yarn install on javascript:build #118

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

Closed
IsmailM opened this issue Jun 15, 2022 · 2 comments
Closed

Avoid running yarn install on javascript:build #118

IsmailM opened this issue Jun 15, 2022 · 2 comments

Comments

@IsmailM
Copy link

IsmailM commented Jun 15, 2022

namespace :javascript do
desc "Build your JavaScript bundle"
task :build do
unless system "yarn install && yarn build"

At the moment, rake javascript:build runs yarn install && yarn build. In my opinion, yarn install should not be part of the javascript building step at all. If it needs to be there, there should at least be an option to disable this (e.g. by having a separate task for yarn install - which can be overwritten or via a ENV variable etc.).

css-bundling does the same thing - so if you are using both css-bundling and js-bundling gems, assets-precompile will run yarn install twice.

Not only does this take slightly longer, it means post-install scripts are run multiple times...

Also, see rails/webpacker#405.

@gsouf
Copy link

gsouf commented Jun 16, 2022

@IsmailM I believe like you that install should not be part of it. But it's sadly not the philosophy of this package #107 (comment)

You can just overwrite the build task, they said. That to me is equivalent to not using this gem as apart from the task it does not do much. In my case I just removed the gem and used my own task

@dhh dhh closed this as completed Jun 18, 2022
@p-schlickmann
Copy link

If anyone is facing this on 2024. They've added a flag SKIP_YARN_INSTALL.

See: https://github.com/rails/jsbundling-rails/blob/main/lib/tasks/jsbundling/build.rake#L18C3-L18C92

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

No branches or pull requests

4 participants