Comments (5)
Hey @jasonfb, thanks for opening an issue!
When I follow your instructions I do get the same result (unstyled text), however I think most of the setup is working correctly and something else is going wrong.
The task to compile the tailwind css file is added to my package.json, and referenced in the Procfile:
diff --git a/Procfile.dev b/Procfile.dev
index 03c54b1..2b0b260 100644
--- a/Procfile.dev
+++ b/Procfile.dev
@@ -1,2 +1,3 @@
web: bin/rails server -p 3000
js: yarn build --watch
+css: yarn build:css --watch
diff --git a/package.json b/package.json
index efca9a3..e9c8f45 100644
--- a/package.json
+++ b/package.json
@@ -4,9 +4,13 @@
"dependencies": {
"@hotwired/stimulus": "^3.2.1",
"@hotwired/turbo-rails": "^7.2.4",
- "esbuild": "^0.16.1"
+ "autoprefixer": "^10.4.13",
+ "esbuild": "^0.16.1",
+ "postcss": "^8.4.19",
+ "tailwindcss": "^3.2.4"
},
"scripts": {
- "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets"
+ "build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets",
+ "build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify"
}
}
And I can see the compiled file get loaded on my page:
However, the thing that's missing is all of the specific classes we added to the partial. This most likely has to do with the view not being in the list of content
in tailwind.config.js
.
In your reproduction script, app/views/articles/index.html.erb
gets renamed to app/views/articles/index.erb
, which isn't in content
list regex by default:
If you rename the file back to app/views/articles/index.html.erb
, then tailwind should see the classes and not purge them from the generated sheet:
Let me know if that works for you, or if you are still seeing issues, happy to help!
from cssbundling-rails.
the problem here is that this app is expecting a tailwind watcher rake task which does not exist in cssbundling-rails, but only exists in tailwind-rails
Procfile.dev
css: bin/rails tailwindcss:watch
but there is no such rake task
rake tasks -T tailwindcss:watch
(no results)
the rake task exists in tailwind-css rails
https://github.com/rails/tailwindcss-rails/blob/main/lib/tasks/build.rake
from cssbundling-rails.
this is (easily) fixed by adding the second Gem. however, the README leads one to believe that tailwind will work with just cssbundling-rails
bundle add tailwindcss-rails
rails tailwindcss:install
from cssbundling-rails.
Note: What's a little extra confusing here is that rails new --css=tailwind
creates new Rails app with tailwindcss-rails and NOT cssbundling-rails, so the rails new --css=tailwind
path is inconsistent with its rails new --css=bootstrap
counterpart.
I believe the installer (bundle add cssbundling-rails && rails css:install:tailwind
) is trying to do the right thing, I'm just not sure how it is supposed to (/able to?) work without that rake task tailwindcss:watch
. Even if you have a node-managed packages (a package.json file), you still would ned to be calling that rake task . (unless there's some other watcher mechanism that I'm not seeing)
from cssbundling-rails.
Correctumundo! Changed name of issue "tailwind fails if you leave the .html format off of your /app/views/ filenames"
from cssbundling-rails.
Related Issues (20)
- set-script has been removed from npm 9 HOT 1
- Compilation step not copying over built css to public/assets folder HOT 4
- Error: The linux-x64 architecture is incompatible with this module, link skipped. HOT 1
- why does `rails new Xyz --css=bootstrap --js=esbuild` not produce working (JS) bootstrap? HOT 5
- Sprockets error when using additional CSS files HOT 1
- Using images inside node_modules HOT 4
- Rails 5 + ruby 2.5 support HOT 1
- Deprecation warning HOT 1
- Propshaft unable to find assets installed via yarn HOT 2
- Regression: Rake task methods override each other HOT 1
- Generating a Rails 7.1.0.beta1 app with bootstrap throws an error HOT 2
- Incorrectly escaped script command
- Possible issue with escaping string at lib/install/bootstrap/install.rb HOT 6
- Allow npm instead of yarn HOT 1
- Surprised by Bun default on new Rails project HOT 1
- How can I handle multiple "root" scss files? HOT 2
- Watch Command w/ Bootstrap Fails to Pick Up Changes HOT 1
- bin/dev file collision, could it be prevented ? HOT 2
- How to remove a framework installation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cssbundling-rails.