Comments (6)
Dealing with the evolution of asset handling in Rails has definitely been one of the biggest challenges (and energy drains) in developing Trestle and it's something that continually plays on my mind as to how it should work in future releases, especially with the multitude of new asset compilation options available now or in the near future.
To give you and idea of how it currently works, the CSS (and JS) in Trestle currently is split into two -- the core bundle and the theme. The core bundle today is shipped precompiled and minified -- see bundle.css -- using a process that is conceptually pretty similar to cssbundling-rails but with a custom webpack build step.
Whilst Trestle currently has a dependency on sprockets-rails
, this approach should also work fine with Propshaft, although I haven't dived into that yet. There may be some complications as I also use .erb
assets to ensure only the relevant i18n asset files are loaded.
The theme files are where the SCSS comes into play. This load path is only added when Trestle.config.theme
is enabled, which by default is if a Sass
or SassC
constant is present. On a new Rails 7 app, you'll probably find this not to be the case. Confusingly, the error you see is coming from the app/assets/trestle/_*.scss
partials created by the trestle:install
generator, and deleting those files (also run rails tmp:cache:clear
) should resolve it, albeit without any custom theming.
So where to going forward? I've been busy working in a private branch on a major rewrite of the front-end JS & CSS, which includes Turbo/Stimulus, Bootstrap 5.1, etc. I'm finishing up some private testing very soon so will publish the branch for public testing once I have the major remaining issues resolved.
For theming, it's probably worth looking at a pure HTML variable theming option. I'd deferred this previously due to browser support but Bootstrap 5 drops support for older browsers (IE11) anyway so it's certainly time and hopefully achievable with effectively the same feature set.
With this release, it'll also be time to drop sprockets-rails
as a hard dependency although I will need to make sure it can work in all configurations without Sprockets (e.g. Webpacker only). I also want to explore the ability to create a fully custom admin bundle by importing only the desired JS/CSS files from a Trestle NPM package.
from trestle.
Any news with the new rails' way of handling the front-end?
from trestle.
Thank you! That's great to know - my app is greenfield Rails 7 and I'd love to lose my Sprockets/SASS dependencies. With the frontend part of Rails in so much flux right now it's pretty hard to see where things are going, though.
from trestle.
I would be interested about this too!
from trestle.
Hey, @spohlenz! Any news with this issue? How can we help you?
from trestle.
~/Code/mhenrixon/cosmos · (feat/invoicing ±)
➜ rails generate trestle:install 03/12/24 - 9:50 AM
[dotenv] Loaded .env
/Users/mhenrixon/.gem/ruby/3.3.0/gems/sprockets-rails-3.4.2/lib/sprockets/railtie.rb:110:in `block in <class:Railtie>': Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
But did not, please create this file and use it to link any assets that need
to be rendered by your app:
Example:
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
and restart your server
For more information see: https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs
from trestle.
Related Issues (20)
- uninitialized constant custom field rails 7 HOT 3
- Changing date format HOT 3
- Option to disable form as "show" view? HOT 1
- My custom helper not is recognized HOT 2
- How i use concerns at trestle? HOT 1
- Remove Multiple Records From MODEL Page
- WebSockets / action_cable support? HOT 2
- Pagination for a custom index View
- Fix typo for Vietnamese locale HOT 1
- Direct upload or chunked file upload support? HOT 2
- Fails without sassc-rails
- Unable to locate favicon.ico in public folder HOT 1
- Best Way To Provide a Select Dropdown for belongs_to that is optional HOT 2
- Filter with a select list
- Enum Radio Button Missing Current Selection HOT 11
- Errors on check_box fields not displaying HOT 2
- Customize navbar HOT 3
- Mongoid support HOT 2
- Use importmap in Trestle HOT 6
- Fix Brazilian Portuguese translation
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 trestle.