Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running assets:precompile, Propshaft includes individual digested files for all CSS / JS instead of only bundles #227

Open
nickjj opened this issue Dec 27, 2024 · 2 comments

Comments

@nickjj
Copy link

nickjj commented Dec 27, 2024

Hello,

I'm using Rails 8 with Propshaft v1.1.0 along with jsbundling and cssbundling where esbuild is doing the bundling.

After running assets:precompile in production mode the following files are created in public/:

image

The concern here is all of the JS and CSS files. When I was using Sprockets, only the application-xxx.js and application-xxx.css files were created but with Propshaft it's generating digested files for everything.

Based on the Propshaft documentation I thought maybe since bundling is happening with esbuild I could set:

Rails.application.config.assets.excluded_paths << ["app/assets/stylesheets", "app/javascript"]

But this resulted in the same outcome where the excess JS and CSS files were created.

What am I doing wrong?

Edit: this is happening with Sprockets too

Here's the same project but using Sprockets:

image

Is this possibly a Rails 8 change and has nothing to do with Propshaft? Unless I'm crazy (which is very possible), I don't recall all of these files being created in the past by Sprockets. Do we know why they're being created?

@midnight-wonderer
Copy link

I spotted three question marks, I could only help with some.

The digest is intended to be used with Cache-Control: immutable. I hope you already know this, I just provided the answer as feedback to your question.

Assuming that the inverse of this statement is what you want:

Propshaft includes individual digested files for all CSS / JS instead of only bundles

Have you read bypassing the digest step yet?
It is basically Propshaft's interface for working with other build tools (esbuild included); can it solve your problem?
Why or why not?

@theodorton
Copy link
Collaborator

theodorton commented Jan 7, 2025

The reason your excluded_paths config doesn't work is because you're not setting absolute paths. You'll need to use Rails.root.join. From the README:

You can however exempt directories that have been added through the config.assets.excluded_paths. This is useful if you're for example using app/assets/stylesheets exclusively as a set of inputs to a compiler like Dart Sass for Rails, and you don't want these input files to be part of the load path. (Remember you need to add full paths, like Rails.root.join("app/assets/stylesheets")).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants