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: guides/source/asset_pipeline.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,18 +155,18 @@ All of the configured import maps should be attached in `<head>` element of your
155
155
156
156
### Using npm packages via JavaScript CDNs
157
157
158
-
You can use the `./bin/importmap` command that's added as part of the `importmap-rails` install to pin, unpin, or update npm packages in your import map. The binstub uses [`JSPM.org`](https://jspm.org/).
158
+
You can use the `bin/importmap` command that's added as part of the `importmap-rails` install to pin, unpin, or update npm packages in your import map. The binstub uses [`JSPM.org`](https://jspm.org/).
159
159
160
160
It works like so:
161
161
162
-
```sh
163
-
./bin/importmap pin react react-dom
162
+
```bash
163
+
$ bin/importmap pin react react-dom
164
164
Pinning "react" to https://ga.jspm.io/npm:[email protected]/index.js
165
165
Pinning "react-dom" to https://ga.jspm.io/npm:[email protected]/index.js
166
166
Pinning "object-assign" to https://ga.jspm.io/npm:[email protected]/index.js
167
167
Pinning "scheduler" to https://ga.jspm.io/npm:[email protected]/index.js
168
168
169
-
./bin/importmap json
169
+
bin/importmap json
170
170
171
171
{
172
172
"imports": {
@@ -190,38 +190,38 @@ import ReactDOM from "react-dom"
190
190
191
191
You can also designate a specific version to pin:
192
192
193
-
```sh
194
-
./bin/importmap pin react@17.0.1
193
+
```bash
194
+
$ bin/importmap pin react@17.0.1
195
195
Pinning "react" to https://ga.jspm.io/npm:[email protected]/index.js
196
196
Pinning "object-assign" to https://ga.jspm.io/npm:[email protected]/index.js
197
197
```
198
198
199
199
Or even remove pins:
200
200
201
-
```sh
202
-
./bin/importmap unpin react
201
+
```bash
202
+
$ bin/importmap unpin react
203
203
Unpinning "react"
204
204
Unpinning "object-assign"
205
205
```
206
206
207
207
You can control the environment of the package for packages with separate "production" (the default) and "development" builds:
208
208
209
-
```sh
210
-
./bin/importmap pin react --env development
209
+
```bash
210
+
$ bin/importmap pin react --env development
211
211
Pinning "react" to https://ga.jspm.io/npm:[email protected]/dev.index.js
212
212
Pinning "object-assign" to https://ga.jspm.io/npm:[email protected]/index.js
213
213
```
214
214
215
215
You can also pick an alternative, supported CDN provider when pinning, like [`unpkg`](https://unpkg.com/) or [`jsdelivr`](https://www.jsdelivr.com/) ([`jspm`](https://jspm.org/) is the default):
216
216
217
-
```sh
218
-
./bin/importmap pin react --from jsdelivr
217
+
```bash
218
+
$ bin/importmap pin react --from jsdelivr
219
219
Pinning "react" to https://cdn.jsdelivr.net/npm/[email protected]/index.js
220
220
```
221
221
222
222
Remember, though, that if you switch a pin from one provider to another, you may have to clean up dependencies added by the first provider that isn't used by the second provider.
223
223
224
-
Run `./bin/importmap` to see all options.
224
+
Run `bin/importmap` to see all options.
225
225
226
226
Note that this command is merely a convenience wrapper to resolving logical package names to CDN URLs. You can also just lookup the CDN URLs yourself, and then pin those. For example, if you wanted to use Skypack for React, you could just add the following to `config/importmap.rb`:
0 commit comments