From 9feeffe42120677588f79feb8bb5b5d19f9652ec Mon Sep 17 00:00:00 2001 From: Igor Fedoronchuk Date: Thu, 21 May 2026 10:38:43 +0200 Subject: [PATCH] feat: ship npm twin (@activeadmin-plugins/activeadmin_calendar) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bundler-based asset pipelines (Vite, esbuild, cssbundling-rails, webpacker) cannot resolve assets from Ruby gem paths, so the CSS component of this gem has to be reachable as an npm package for those consumers. Mirrors the layout already used by sibling AA plugins (e.g. @activeadmin-plugins/active_admin_sidebar): a thin package.json with `style` + `main` pointing at src/activeadmin_calendar.css, populated on publish by the `prepublishOnly` script which copies from app/assets/stylesheets/. src/ is gitignored — it only exists at publish time, so the gem and npm package share a single CSS source. Propshaft / Sprockets consumers continue to auto-discover the CSS directly from app/assets/stylesheets/ — they don't need the npm package. Consumers on a bundler can now write: @import '@activeadmin-plugins/activeadmin_calendar'; instead of mirroring the CSS locally. --- .gitignore | 5 +++++ package.json | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 54ee17a..039eeb7 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,8 @@ /coverage/ *.gem .byebug_history +# npm package artifacts. `src/` is generated by `npm run prepublishOnly` +# (copy of app/assets/stylesheets/*.css), only present during publish. +/src/ +/node_modules/ +package-lock.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..abb19aa --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "@activeadmin-plugins/activeadmin_calendar", + "version": "1.0.0", + "description": "Calendar index style for ActiveAdmin — CSS for the gem of the same name.", + "style": "src/activeadmin_calendar.css", + "main": "src/activeadmin_calendar.css", + "author": "Igor Fedoronchuk ", + "license": "MIT", + "private": false, + "repository": { + "type": "git", + "url": "git+https://github.com/activeadmin-plugins/activeadmin_calendar.git" + }, + "bugs": { + "url": "https://github.com/activeadmin-plugins/activeadmin_calendar/issues" + }, + "homepage": "https://github.com/activeadmin-plugins/activeadmin_calendar#readme", + "keywords": [ + "active", + "admin", + "calendar" + ], + "files": [ + "src/**/*" + ], + "scripts": { + "prepublishOnly": "rm -rf src && mkdir -p src && cp app/assets/stylesheets/activeadmin_calendar.css src/" + } +}