Commit 5e6758f
authored
Adding --public-path option to the esbuild script (#58)
* Adding --public-path option to the esbuild script
Setting `esbuild ... --public-path=assets` allows client-side code to reference images from the asset pipeline.
Example:
1. Create image at `app/javascript/images/example.png`.
2. Add esbuild option `--loader:.png=file` (not included in this PR).
3. When esbuild runs, it will output e.g. `app/assets/builds/example-5SRKKTLZ.png`.
4. In frontend code, e.g. a React component, add `import Example from "../images/example.png"` .
5. Now the image can be referenced with `<img src={Example} />`.
6. The path resolves to /assets/example-5SRKKTLZ.png. Without this PR, the path resolves to /example-5SRKKTLZ.png.
* Instructions for referencing static assets in frontend code built with esbuild
* Looks like this question should be beneath the FAQ header
* typo1 parent fc66837 commit 5e6758f
2 files changed
+12
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
43 | 53 | | |
44 | 54 | | |
45 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
0 commit comments