rails / cssbundling-rails

Bundle and process CSS in Rails with Tailwind, PostCSS, and Sass via Node.js.
MIT License
579 stars 83 forks source link

Make css:build depend on yarn:install directly #42

Closed zarqman closed 2 years ago

zarqman commented 2 years ago

This PR makes css:build depend on yarn:install directly instead of running yarn install on its own. This ensures yarn install is only run once and not multiple times.

Comparable to rails/jsbundling-rails#43 and rails/jsbundling-rails#49.

This relies on rails/rails#43641 which corrects yarn:install to use yarn via the PATH and not require bin/yarn, which is no longer added in Rails 7.

I believe it's safe to depend on yarn:install directly because cssbundling-rails already depends on railties, so yarn:install should always be available. If this somehow isn't valid, then we could add a no-op version of yarn:install here which would at least avoid errors while also not skipping enhancement as the existing approach does.

dhh commented 2 years ago

Although even looking at all of this, starting to have second thoughts on whether we should even require yarn. Versus just using npm.