[Rails 7] - Help to configure a newly migrated app to process activeadmin assets (js and scss) using jsbundling-rails with esbuild #7947
Replies: 7 comments 3 replies
-
Hi I switched back to webpacker for the moment, because I can see that Active Admin is 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 |
Beta Was this translation helpful? Give feedback.
-
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
|
Beta Was this translation helpful? Give feedback.
-
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 with https://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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
Hi guys, sorry to resurrect this discussion but while this solution works like a charm inside 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! |
Beta Was this translation helpful? Give feedback.
-
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 @guillaumebesse up 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:
import jquery from 'jquery';
window.jquery = jquery; // i mean why not?!
window.jQuery = jquery; // jquery ui is looking for this one
window.$ = jquery; // activeadmin wants this one
import "./add_jquery" // forces hoisting to behave
import './jquery-ui' // jQuery is now defined
import "@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 across this 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. |
Beta Was this translation helpful? Give feedback.
-
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.
I am new to esbuild.
Any help is welcome.
Beta Was this translation helpful? Give feedback.
All reactions