Skip to content

Commit 40b4e4e

Browse files
Fix importmap controller loading for Rails engine
Use File.expand_path to properly reference engine's controller directory in pin_all_from directive, preventing conflicts with host application controllers and resolving asset precompilation errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix importmap controller loading to prevent asset precompilation errors - Replace pin_all_from with explicit controller pinning to avoid loading application.js as a controller - Update index.js to import application from correct path - Only pin actual *_controller.js files under controllers namespace 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Add Tailwind CSS build support for Rails engine - Add rake tasks for building and watching Tailwind CSS - Include builds directory in asset manifest - Configure asset paths to include builds directory - Add .gitignore for generated CSS files - Hook Tailwind build into assets:precompile 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Improve automatic Tailwind CSS build integration - Hook leva:build_css into assets:precompile, assets:clean, and test:prepare - Use engine root paths for proper directory resolution - Register engine's Tailwind build with host app configuration - Automatically build CSS during Rails asset pipeline tasks Now Tailwind CSS builds automatically during: - rails assets:precompile (production deployments) - rails assets:clean (cleanup) - rails test:prepare (test runs) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Add automatic CSS building in development mode - Add file watcher that rebuilds CSS when Tailwind source files change - Watch application.tailwind.css, tailwind.config.js, views, and JS files - Automatically triggers leva:build_css when files are modified - Works seamlessly with Rails development reloader No more manual CSS building needed in development\! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix Tailwind CSS color class inclusion - Update Tailwind config content paths to include absolute engine paths - Add comprehensive safelist of all color classes used in views - Ensure engine's view files are properly scanned by Tailwind - Remove problematic @apply circular references from CSS Colors should now display correctly in the UI\! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix file watcher API usage for CSS auto-rebuilding - Use correct FileUpdateChecker constructor with files and directories - Pass watch_files array and watch_dirs hash instead of using watch() method - Prevents NoMethodError when initializing the engine 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix Pathname to String conversion for FileUpdateChecker - Convert Pathname objects to strings using .to_s before passing to FileUpdateChecker - FileUpdateChecker expects string paths, not Pathname objects - Prevents NoMethodError when trying to call gsub on Pathname 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Remove automatic CSS file watching in development - Remove complex file watcher that was causing initialization errors - CSS can be built manually with 'rake leva:build_css' when needed - Automatic building still happens during assets:precompile for production - Simpler and more reliable approach 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Add one-time CSS build on engine load in development - Build CSS automatically when engine loads in development - Runs after :load_config_initializers to ensure rake tasks are available - No file watching overhead, just builds once when needed - Graceful error handling with warning instead of crash 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix CSS build by running tailwind command directly - Run tailwind CLI directly instead of invoking rake task - Rake tasks may not be loaded when initializer runs - Use same logic as leva:build_css task but inline - Add logging to show when CSS is building - Ensure builds directory exists before building 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix rake task invocation by loading tasks first - Use Rails.application.load_tasks to ensure rake tasks are loaded - Then invoke the leva:build_css rake task as intended - Keep the nice rake task approach - Add logging to show when CSS is building 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Add individual JS controller files to asset precompilation - Explicitly add all *_controller.js files to assets.precompile - Add index.js to precompilation list - Ensures individual controller files are available in production - May fix JS loading issues in development/production 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Remove conditional check for javascript_importmap_tags - Always load importmap tags instead of checking respond_to? - The conditional might have been preventing importmap from loading - Ensures JavaScript assets are always included 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix importmap controller paths - Update controller pins to include full path: controllers/filename.js - Add explicit pin for controllers/application.js - Fix "Importmap skipped missing path" errors - Controllers should now load correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Use pin_all_from for automatic JavaScript file loading - Replace manual controller pinning with pin_all_from - Use File.expand_path to ensure absolute path - Pin all JavaScript files from app/javascript directory - Simpler and follows Rails importmap best practices 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]) Fix controller registration with proper namespacing - Pin controllers under "controllers" namespace for eagerLoadControllersFrom - Explicitly pin controllers/index.js and controllers/application.js - Add "to" parameter to ensure correct file paths - Controllers should now register with their proper names 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix asset manifest using link_tree for controllers - Use link_tree for controllers directory instead of individual files - Update index.js to import application from controllers/application - Follows Rails engine best practices for asset organization - Simpler and more maintainable approach 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Fix importmap paths to match asset pipeline serving - Pin controllers without "controllers/" prefix in the "to" parameter - Add explicit link for application.js in manifest - Map import names to actual served file paths - Should resolve AssetNotPrecompiledError for controllers/index.js 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Simplify importmap configuration with correct paths - Use pin_all_from with Engine.root for proper path resolution - Keep controllers under "controllers" namespace - Restore simple asset manifest with link_tree - Controllers index.js was already correct 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Update asset manifest and importmap configuration - Replace application.js with new path for leva/application.js - Adjust asset manifest to link JavaScript files from ../../javascript/leva - Update importmap to pin controllers from the new leva/controllers directory - Clean up unnecessary links and ensure proper file structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Reorganize JavaScript files under leva namespace - Move controllers to app/javascript/leva/controllers/ - Create application.js in leva directory - Match the new importmap and manifest structure - Files are now in correct locations for loading 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> fix
1 parent 996408b commit 40b4e4e

32 files changed

+182
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
/test/dummy/storage/
1010
/test/dummy/tmp/
1111
.worktrees
12+
/app/assets/builds/

app/assets/config/leva_manifest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
//= link_directory ../stylesheets/leva .css
2-
//= link_tree ../../javascript .js
3-
//= link_tree ../../../vendor/javascript .js
2+
//= link_directory ../../javascript/leva .js
3+
//= link_tree ../../javascript/leva/controllers .js

app/javascript/application.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/javascript/controllers/application.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/javascript/controllers/index.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/javascript/leva/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "controllers"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Application } from "@hotwired/stimulus";
2+
3+
const application = Application.start();
4+
5+
// Configure Stimulus development experience
6+
application.debug = false;
7+
window.Stimulus = application;
8+
9+
export { application };

app/javascript/controllers/clipboard_controller.js renamed to app/javascript/leva/controllers/clipboard_controller.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
44
static targets = ["content"]
5+
6+
connect() {
7+
console.log("Clipboard controller connected!")
8+
}
59

610
copy(event) {
711
const sourceId = event.currentTarget.dataset.clipboardSource

0 commit comments

Comments
 (0)