All threads / splitting asset pipeline for front and backend

Ask A Question

Notifications

You’re not receiving notifications from this thread.

splitting asset pipeline for front and backend

Peter vande Put asked in Rails

app has a consumer facing part and large backend/CMS part.
our assets (JS and SCSS) are precompiled into a very large file
in layouts we have a different layout for front- and backend

Is it possible to split assets:precompile into a front end and a backend part?

using asset_sync gem and fog

My understanding of your situation is that you have 2 different systems sharing the same JS and SCSS and therefore compiling into 1 big JS file and 1 big CSS file?

If that's the case and you're using Sprockets/AssetPipeline, you can split your CSS/JS into multiple folders with the main file named application.js or application.scss and Rails will compile them separately. Same can be done with Javascript.

Example:

# assets/stylesheets/backend/application.scss
# assets/stylesheets/frontend/application.scss

In your layout's stylesheet_link_tag, you just have to update the path accordingly.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 38,558+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.