Git Product home page Git Product logo

Comments (6)

spohlenz avatar spohlenz commented on June 3, 2024 3

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.

pedrofs avatar pedrofs commented on June 3, 2024 1

Any news with the new rails' way of handling the front-end?

from trestle.

johanhalse avatar johanhalse commented on June 3, 2024

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.

vizcay avatar vizcay commented on June 3, 2024

I would be interested about this too!

from trestle.

alec-c4 avatar alec-c4 commented on June 3, 2024

Hey, @spohlenz! Any news with this issue? How can we help you?

from trestle.

mhenrixon avatar mhenrixon commented on June 3, 2024
~/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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.