Skip to content

--javascript option causes support for tailwind styled scaffold templates not to be installed #43531

Closed
@rubys

Description

@rubys

Steps to reproduce

(rm -rf depot; \
rails new depot -j esbuild --css tailwind; \
cd depot; \
bin/rails generate scaffold Product title:string; \
grep class app/views/products/show.html.erb)

Expected behavior

The generated view should contain class attributes utilizing tailwind classes.

Actual behavior

No class attribute are defined

Additionally, errors are produced when generating the tailwind class:

         rails  css:install:tailwind
  Build into app/assets/builds
         exist  app/assets/builds
     identical  app/assets/builds/.keep
- File unchanged! The supplied flag value not found!  app/assets/config/manifest.js
  Stop linking stylesheets automatically
        gsub  app/assets/config/manifest.js
- File unchanged! The supplied flag value not found!  .gitignore
- File unchanged! The supplied flag value not found!  .gitignore
  Remove app/assets/stylesheets/application.css so build output can take over
        remove  app/assets/stylesheets/application.css
  Add stylesheet link tag in application layout
- File unchanged! The supplied flag value not found!  app/views/layouts/application.html.erb
        append  Procfile.dev
  Add bin/dev to start foreman
     identical  bin/dev
  Install Tailwind (+PostCSS w/ autoprefixer)
        create  tailwind.config.js
        create  app/assets/stylesheets/application.tailwind.css
           run  yarn add tailwindcss@latest postcss@latest autoprefixer@latest from "."

Note: no errors are produced, and class attributes making use of tailwind classes are added if the -j esbuild option is removed from the rails command in the test case above.

Analysis/commentary

The tailwindcss_rails gem has a nice feature whereby it provides Tailwind styled scaffold templates: rails/tailwindcss-rails#71

Rails, by default, will install tailwindcss_rails via tailwindcss:install unless the js option is specified, see:

if !using_node? && options[:css] == "tailwind"
GemfileEntry.version("tailwindcss-rails", ">= 0.4.3", "Use Tailwind CSS. See: https://github.com/rails/tailwindcss-rails")
else
GemfileEntry.version("cssbundling-rails", ">= 0.1.0", "Bundle and process CSS with Tailwind, PostCSS, or Sass. Read more: https://github.com/rails/cssbundling-rails")
end

This was added with the following commit:
8380816#diff-a83245368df35c610a37260d0a51041de89211857d47cfd0b2d1301a11709164R409-R412

Likely one of the following two options will need to be done to fix this problem:

  • css:install:tailwind (and therefore, cssbundling-rails) will install tailwindcss_rails in addition to what it is currently doing
  • rails will need to install both cssbundling-rails and tailwindcss_rails

Either way, the errors produced by css:install:tailwind should be addressed.

System configuration

Rails version:
Rails 7.0.0.alpha2

Ruby version:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions