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

Sprockets AssetNotPrecompiledError in Rails 7 #103

Closed
onurozer opened this issue Jun 6, 2022 · 4 comments
Closed

Sprockets AssetNotPrecompiledError in Rails 7 #103

onurozer opened this issue Jun 6, 2022 · 4 comments

Comments

@onurozer
Copy link

onurozer commented Jun 6, 2022

Hi,

I am using Rails 7 with esbuild and tailwind css. I tried adding attachment: Field::ActiveStorage, to an Active Storage field in administrate and got this error:

Sprockets::Rails::Helper::AssetNotPrecompiledError

Asset `administrate-field-active_storage/application.css` was not declared to be precompiled in production.
Declare links to your assets in `app/assets/config/manifest.js`.

  //= link administrate-field-active_storage/application.css

Administrate doesn't seem to support Rails 7 yet, so I'm using a fork.

The error I'm getting seems to be similar to the problem with the original administrate branch regarding asset compilation, but I may be wrong.

Is there a way to get this plugin to work with Rails 7 defaults and administrate?

Thank you.

@Dreamersoul
Copy link
Owner

I haven't looked into it yet if you find a fix please feel free to submit a PR

@edudepetris
Copy link

@onurozer have you tried to add //= link administrate-field-active_storage/application.css into your manifest? (example)

@Dreamersoul
Copy link
Owner

no response from issue creator. closing for now.
please open a new issue if you still having issues 👍🏻

@clayton
Copy link

clayton commented Sep 14, 2023

This is still happening with rails 7.0.7

The error:

Asset `administrate-field-active_storage/application.css` was not declared to be precompiled in production.
Declare links to your assets in `app/assets/config/manifest.js`.

  //= link administrate-field-active_storage/application.css

Modifying app/assets/config/manifest.js to include the snippet above:

//= link administrate-field-active_storage/application.css
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
//= link_tree ../builds

I ran rails assets:clobber for good measure and restarted the server.

Seems to have fix the issue, but noticed some errors with my rspec feature specs. Not sure if related.

Getting this error when precompiling assets for production RAILS_ENV=production bin/rails assets:precompile

#0 3.044 SassC::SyntaxError: Error: Function rgb is missing argument $green.
#0 3.044         on line 1070 of stdin
#0 3.044 >>   border-color: rgb(243 244 246 / var(--tw-divide-opacity));
#0 3.044 
#0 3.044    ----------------^

Which is covered here #107

Ultimately found the fix here: thoughtbot/administrate#2091 (comment)

# in config/environments/production.rb

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
config.assets.css_compressor = nil

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

4 participants