-
Notifications
You must be signed in to change notification settings - Fork 22k
Improve js and css options of app generator #47689
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 js and css options of app generator #47689
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me, but it would be good to add some tests.
I am pushing a commit to add test coverage and address my comments. Let me know what you think.
options[:javascript] && options[:javascript] != "importmap" | ||
options[:javascript] != "importmap" || options[:css] && !%w[tailwind sass].include?(options[:css]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options[:javascript]
does have a default value ("importmap"
), but specifying --no-javascript
would set it to nil
, so let's keep the presence check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
if !using_node? && options[:css] == "tailwind" | ||
if options[:css] == "tailwind" && options[:javascript] == "importmap" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using_node?
is the correct condition here, and it makes the intent more clear. Is there a reason to not use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good for me! I have used form options[:javascript] == "importmap"
because it has been a literal translation of the PR table, but it seems to me a successful change.
This allows the `importmap-rails` gem to be used when using the `cssbundling-rails` gem. It also ensures that Node-related files (e.g. `.node-version`) are added when using the `cssbundling-rails` gem. Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
Thank you, @javierav! 📦 |
Motivation / Background
This Pull Request has been created because the Rails app generator currently has two issues:
First issue
If I choose
importmap
as the javascript option andbootstrap
,bulma
orpostcss
as the css option, rails forces me to useesbuild
as the javascript option, ignoring my choice ofimportmap
.There should be no problem using
importmap
as a javascript option and usingbootstrap
,bulma
orpostcss
with Node.jsSecond issue
If I choose
importmap
as the javascript option, the.node-version
file is not created and theDockerfile
does not include the Node.js installation steps, even when Rails forces it to useesbuild
(first issue) or if we are using a css option that requires Node.jsDetail
This Pull Request changes the requirements for the
.node-version
file to be created and theDockerfile
to include the Node.js installation.It also changes the old behavior and if I choose
importmap
it uses it regardless of the css option selected.Actual behavior
cssbundling-rails
css:install:*
tailwindcss-rails
tailwindcss:install
dartsass-rails
dartsass:install
cssbundling-rails
css:install:*
Proposed behavior
cssbundling-rails
css:install:*
tailwindcss-rails
tailwindcss:install
dartsass-rails
dartsass:install
cssbundling-rails
css:install:*
Still, there is a combination that is not possible: if I want to use
importmap
andcssbundling-rails
to compile the css usingtailwind
orsass
instead of usetailwindcss-rails
ordartsass-rails
.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
Footnotes
no install node (required by jsbundling-rails) and change importmap to esbuild ↩