Skip to content

ursm/importmap-rails-assets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

importmap-rails-assets

Vendor arbitrary assets (CSS, fonts, images, etc.) from packages pinned with importmap-rails.

Supported versions

  • Ruby 3.3+
  • importmap-rails 2.1+

Installation

Add to your Gemfile:

gem 'importmap-rails-assets'

Usage

Define asset mappings in config/assets.yml. Each key is an npm package name (as pinned in your importmap), and the value is a hash of source paths within the package to local destination paths:

tom-select:
  dist/css/tom-select.bootstrap5.css: vendor/assets/stylesheets/tom-select.css

flatpickr:
  dist/flatpickr.css: vendor/assets/stylesheets/flatpickr.css
  dist/themes/dark.css: vendor/assets/stylesheets/flatpickr-dark.css

Then pin the package as usual:

$ bin/importmap pin flatpickr
Pinning "flatpickr" to vendor/javascript/flatpickr.js via download from https://ga.jspm.io/npm:flatpickr@4.6.13/dist/flatpickr.js
Downloading "flatpickr/dist/flatpickr.css" to vendor/assets/stylesheets/flatpickr.css
Downloading "flatpickr/dist/themes/dark.css" to vendor/assets/stylesheets/flatpickr-dark.css

bin/importmap update and bin/importmap pristine also download assets in the same way.

bin/importmap unpin removes the corresponding asset files as well.

License

MIT

About

Vendor arbitrary assets (CSS, fonts, images, etc.) from packages pinned with importmap-rails

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages