From b03c6e9513865eb253cd4841b5cc323635291863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Tue, 7 Mar 2023 18:30:09 +0800 Subject: [PATCH] Support vendoring npm module code --- README.md | 8 ++++++++ app/assets/config/manifest.js | 1 + bin/importmap | 4 ++++ config/importmap.rb | 1 + 4 files changed, 14 insertions(+) create mode 100755 bin/importmap diff --git a/README.md b/README.md index df1a1e9..f14c3de 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,13 @@ The setup task will first delete any existing entries in the directory tree Note that all 389ds data is stored in `tmp/389ds`. So if you want to start over with a fresh installation, delete both that directory as well as the container. +### Adding npm modules to use with Stimulus controllers + +The following command downloads the specified npm module to `vendor/javascript` +and adds an entry for it to `config/importmap.rb`. + + bin/importmap pin bech32 --download + ### Solargraph [Solargraph](https://solargraph.org/) is a Ruby language server, which you may @@ -98,6 +105,7 @@ command: * [Tailwind CSS](https://tailwindcss.com/) * [Sass](https://sass-lang.com/documentation) +* [Stimulus](https://stimulus.hotwired.dev/handbook/) ### Testing diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index bff5c5b..4d205bf 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,3 +1,4 @@ //= link_tree ../images //= link_tree ../../javascript .js //= link_tree ../builds +//= link_tree ../../../vendor/javascript .js diff --git a/bin/importmap b/bin/importmap new file mode 100755 index 0000000..36502ab --- /dev/null +++ b/bin/importmap @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +require_relative "../config/application" +require "importmap/commands" diff --git a/config/importmap.rb b/config/importmap.rb index 8dce42d..17d5cd6 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -5,3 +5,4 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true pin_all_from "app/javascript/controllers", under: "controllers" +pin "bech32" # @2.0.0