Skip to content

Commit a66e8a0

Browse files
committed
Updated README for pin_all_from issue
1 parent 09ed1a4 commit a66e8a0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,26 @@ It's in `app/javascript/application.js` you setup your application by importing
6464
It makes sense to use logical names that match the package names used by npm, such that if you later want to start transpiling or bundling your code, you won't have to change any module imports.
6565

6666
### Local modules
67+
6768
If you want to import local js module files from `app/javascript/src` or other sub-folders of `app/javascript` (such as `channels`), you must pin these to be able to import them.
6869
You can use `pin_all_from` to pick all files in a specific folder, so you don't have to `pin` each module individually.
70+
6971
```rb
7072
# config/importmap.rb
7173
pin_all_from 'app/javascript/src`, under: 'src', to: 'src'
7274
```
7375
74-
Allows you to
76+
The `:to` parameter is only required if you want to change the destination logical import name. If you drop the :to option, you must place the :under option directly after the first parameter.
77+
78+
Allows you to:
79+
7580
```js
7681
// app/javascript/application.js
7782
import { ExampleFunction } from 'src/example_function'
7883
```
7984
Which imports the function from `app/javascript/src/example_function.js`.
8085
81-
Note: Sprockets used to serve assets (albeit without filename digests) it couldn't find from the app/javascripts folder with logical relative paths, meaning pinning local files wasn't needed. Propshaft doesn't have this fallback, so when you use Propshaft you have to pin your local modules.
86+
Note: Sprockets used to serve assets (albeit without filename digests) it couldn't find from the `app/javascripts` folder with logical relative paths, meaning pinning local files wasn't needed. Propshaft doesn't have this fallback, so when you use Propshaft you have to pin your local modules.
8287

8388
## Using npm packages via JavaScript CDNs
8489

0 commit comments

Comments
 (0)