You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-7Lines changed: 16 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -97,19 +97,29 @@ Note: Sprockets used to serve assets (albeit without filename digests) it couldn
97
97
98
98
Importmap for Rails downloads and vendors your npm package dependencies via JavaScript CDNs that provide pre-compiled distribution versions.
99
99
100
-
You can use the `./bin/importmap` command that's added as part of the install to pin, unpin, or update npm packages in your import map. This command uses an API from [JSPM.org](https://jspm.org) to resolve your package dependencies efficiently, and then add the pins to your `config/importmap.rb` file. It can resolve these dependencies from JSPM itself, but also from other CDNs, like [unpkg.com](https://unpkg.com) and [jsdelivr.com](https://www.jsdelivr.com).
100
+
You can use the `./bin/importmap` command that's added as part of the install to pin, unpin, or update npm packages in your import map. By default this command uses an API from [JSPM.org](https://jspm.org) to resolve your package dependencies efficiently, and then add the pins to your `config/importmap.rb` file.
101
101
102
102
```bash
103
103
./bin/importmap pin react
104
-
Pinning "react" to vendor/react.js via download from https://ga.jspm.io/npm:[email protected]/index.js
105
-
Pinning "object-assign" to vendor/object-assign.js via download from https://ga.jspm.io/npm:[email protected]/index.js
104
+
Pinning "react" to vendor/javascript/react.js via download from https://ga.jspm.io/npm:[email protected]/index.js
106
105
```
107
106
108
-
This will produce pins in your `config/importmap.rb` like so:
107
+
This will produce a pin in your `config/importmap.rb` like so:
Other CDNs like [unpkg.com](https://unpkg.com) and [jsdelivr.com](https://www.jsdelivr.com) can be specified with `--from`:
114
+
115
+
```bash
116
+
./bin/importmap pin react --from unpkg
117
+
Pinning "react" to vendor/javascript/react.js via download from https://unpkg.com/[email protected]/index.js
118
+
```
119
+
120
+
```bash
121
+
./bin/importmap pin react --from jsdelivr
122
+
Pinning "react" to vendor/javascript/react.js via download from https://cdn.jsdelivr.net/npm/[email protected]/index.js
113
123
```
114
124
115
125
The packages are downloaded to `vendor/javascript`, which you can check into your source control, and they'll be available through your application's own asset pipeline serving.
@@ -119,7 +129,6 @@ If you later wish to remove a downloaded pin:
0 commit comments