Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.3k
[Rails 7] - Help to configure a newly migrated app to process activeadmin assets (js and scss) using jsbundling-rails with esbuild#7947
-
Thanks to the work in progress in PR#7235, activeadmin is starting. But I don't know how to deal with active_admin.js and my custom scss files. Any help is welcome. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3
Replies: 9 comments 10 replies
-
Hi I switched back to webpacker for the moment, because I can see that Active Adminis using jQuery UI and this library does not play well with esbuild by default I think this resource could be helpful:https://gorails.com/episodes/how-to-use-jquery-with-esbuild It requires to download custom assets from jquery-ui and I'm not comfortable in doing that Slightly refers to#7226 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I did some progress, everything is not tested but It is really promising. The goal is to compile in
Files tree
1/ In package.json, I have application.tailwind.css: I regroup all my CSS this file active_admin.scss active_admin.js |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
-
I wanted to get this working with rails 7 and esbuild and took the nuclear option 😅
And it works! It might have been possible to make it work withhttps://github.com/excid3/esbuild-rails but jquery-ui needs a custom build. If activeadmin can publish a gem with assets precompiled, it will be much easier to use. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 4
-
I have a similar issue, although it is entangled with my limited understanding of the new Rails 7 css and js options. I created a new Rails 7 app with After installing and visiting |
BetaWas this translation helpful?Give feedback.
All reactions
👀 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I also face the same issue using Did you find any solution to make the |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
I successfully manage to install To handle the I've added the following snippet to mimic Webpacker methods the Ensure you have
No issues so far, but I guess jquery-ui components would require explicit importing |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 14
-
This was super helpful! I also had to add this for favicons: # in ActiveAdmin.configconfig.favicon='images/favicon.png'# In ActiveAdminViteJSdeffavicon_pack_tag(favicon)favicon_link_tag(vite_asset_path(favicon))end |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thank you, this really helped! However, I got an error: I think this is running in another context because it is used for Devise. I was able to fix it by patching the - ActiveAdmin::Views::Pages::Base.include ActiveAdminViteJS+ ActiveAdmin::ViewHelpers.include ActiveAdminViteJS |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi guys, sorry to resurrect this discussion but while this solution works like a charminside Active Admin, I can't seem to get the sign in page working. I keep getting the following error: I already removed most of the webpacker files and configs, but I can't seem to find the place to make this particular page working, which means I can't log in to Active Admin at all. Any help would be greatly appreciated! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi all, I've been back to this url several times in the last week, I wanted to report on my progress and what i think is a tenable solution for my needs. I started with the snippets from@guillaumebesseup there☝️ . This was perfect to get me css / scss compiling and get me on the right track but as soon as i added inline forms that required javascript (has_many, nested attributes) is when I noticed the javascript was not getting built.
import"@activeadmin/activeadmin"; issue: web conole reports
solution (I think): declare the build to be a module in "module":"true","dependencies": {"@activeadmin/activeadmin":"^3.0.0",... Issue: jquery is not defined:
importjqueryfrom'jquery';window.jquery=jquery;// i mean why not?!window.jQuery=jquery;// jquery ui is looking for this onewindow.$=jquery;// activeadmin wants this one
import"./add_jquery"// forces hoisting to behaveimport'./jquery-ui'// jQuery is now definedimport"@activeadmin/activeadmin"; Final issue, jQuery UI when loaded from node_modules has a ton of load dependencies outside the initial widget.js, as you can see from the above import, I vendored jquery-ui instead of using it from the node modules. you can download the full version from the website. I finally came acrossthis video which ended up being really useful to get that final step. % tree app/javascript app/javascript├── active_admin.js├── add_jquery.js├── application.js├── controllers│ ├── application.js│ ├── hello_controller.js│ └── index.js└── jquery-ui.js Like often, javascript has taken hours off of my life, but I'm super grateful to not be in the business of building forms, so thanks ActiveAdmin folks. Hopefully this helps streamline the process for others on Rails 7 and esbuild. |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 2
-
I've successfully configured ActiveAdmin version 3.2 in my Rails project with jsbundling-rails, and propshaft, all managed via node_modules. Here's the setup that worked for me: //app/javascript/active_admin.jsimport'./add_jquery'import'jquery-ui'import"jquery-ujs"import'jquery-ui/ui/unique-id.js'import'jquery-ui/ui/widgets/mouse'import"jquery-ui/ui/widgets/sortable"import"jquery-ui/ui/widgets/tabs"import"jquery-ui/ui/widgets/dialog"import'jquery-ui/ui/widgets/datepicker'import'jquery-ui/ui/widget'import'@activeadmin/activeadmin' |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 2
-
Dang I didn't follow the discussion from the original issue and wasted so much time with vite inject and other configuration trying to get jquery_ui to load properly. I ended up doing exactly this yesterday after losing a day on it. I believe the reason for this is the order on how Vite transforms CJS imports when |
BetaWas this translation helpful?Give feedback.
All reactions
-
This should work with jsbundling-rails and our NPM package as is. I think the issue may be that we aren't specifying the ESM file in a |
BetaWas this translation helpful?Give feedback.
All reactions
-
It doesn't seem we are building a proper ESM version for v3. I'll try to see if we canimplement what ActionView did for rails-ujs for bundling an additional ESM file with our rollup config. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I have a PR that adds a new |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I'm not sure if this is necessarily still an issue for people but i was able to get this resolved with two steps. This seems to be acceptable considering the new propshaft asset model handling: Roughly: transpile with dartsass-rails. That means running the set up for dartsass-rails and then i added a build step in My initializer for You should do the above to make sure that your application css won't get clobbered by active_admin css. nothing else is really needed, propshaft will deliver the correct asset once it's transpiled for active admin css to use because active admin is using stylesheet_link_tag i believe Then in the active_admin initializer you need to add this configuration: I had trouble actually figuring out the javascript. I tried esbuild to bundle the smaller files but that was leading to some other issues with imports and what not and seemed like a rabbit hole. Credit for the javascript goes to Henrik on medium:https://henrikbjorn.medium.com/til-using-activeadmin-with-importmap-rails-289cde6f76b8 He also has a section on importmaps but i don't fully understand importmaps yet so ... anyways hope the above is helpful especially for people integrating activeadmin with rails 8. This seems to fully work, at least I tested one delete action and was able to successfully delete a resource on the admin backend. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
tldr: To use Active Admin v3 with Propshaft, puthttps://gist.github.com/losnikitos/46b4fb8c63bfd14577299611ec90f61b into I had a problem with missing js bundle after migrating from Sprockets to Propshaft (Rails 7, Active Admin v3). My Which Sprockets would have picked up and assembled a bundle, but Propshaft wouldn't. What I did was 'quick and dirty' solution: I assembled a bundle with sprockets ( |
BetaWas this translation helpful?Give feedback.
All reactions
This discussion was converted from issue #7264 on May 11, 2023 02:39.