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
manifest.js
and dynamic assets to link
#654
Comments
Hi @vfonic were you able to find a solution to this? |
I've restricted sprockets to gem 'sprockets', '< 4' |
Been there till now, but I need to switch to webpacker (because of a library with es6 modules that I have to use) and thought - why not upgrade sprockets along the way as webpacker does not solve a lot of the problems and even introduces more of them and you have to use both sprockets and webpacker. Turns out it is far from possible to upgrade sprockets and even expect the same feature set. |
I use webpacker and sprockets in the same project. I'd advise you to try sticking to both and slowly completely switch to webpacker. |
@vfonic thanks for the workaround, looks like keep sprockets behind version 4 is the only way to keep this working: Rails.application.config.assets.precompile += ["my_engine/namespace/*.css"] |
From the upgrade guide, and successfully tested in my own app, the following still works with Sprockets 4:
I migrated all the files and directories I could to manifest.js, and for one that was too tedious to do so (Ckeditor assets) I added the precompile directive as below. As far as I can tell it's working fine.
|
The old way still works. You can continue doing: Rails.application.config.assets.precompile += BulletTrain.available_apps.map do |app_name|
app_symbol = app_name.parameterize.underscore
[
"apps/#{app_symbol}/#{BulletTrain::JAVASCRIPT_ASSET_NAME}",
"apps/#{app_symbol}/#{BulletTrain::STYLESHEET_ASSET_NAME}"
]
end.flatten But you still need a manifest for when dynamic is needed. |
I just upgraded to sprockets 4 and, as many other developers, have had negative experience with the new
manifest.js
file requirement.I also believe this change should have been done in a less breaking way. It could be a warning or, even better, the old behavior should continue working (I don't see what's stopping the old behavior from working?).
In my current, working, app. I have this in
config/initializers/assets.rb
:This, based on the
available_apps
array, dynamically adds all the required assets for precompilation.I upgraded sprockets, was met with the notorious error about missing
manifest.js
and tried to fix it:I also tried:
But that also didn't work (
Sprockets::Railtie::ManifestNeededError
).I also tried:
...which is not providing the same functionality (all apps' assets are not being precompiled, not only available apps)
But I hit a different bug that I'll open a new issue for (more on that below).
Expected behavior
The old behavior just works.
Actual behavior
There's no way to achieve the same functionality in the new release.
System configuration
Example App (Reproduction)
I'm afraid I've discovered unrelated issue while trying to create example app:
https://github.com/vfonic/no-rockets-for-sprockets
If you start
rails server
, the app will fail (or it won't). It's intermittently failing. (I'll create a separate issue.)I've also followed the UPGRADING guide:
https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs
I don't see
manifest.js
being added for precompilation after doingrails new
. Is it necessary to add that manually to old apps? The upgrading guide seems to be confusing. I'd believe I have to add this, yet I see new rails apps work without having that added.Related: #643
The text was updated successfully, but these errors were encountered: