Skip to content

Commit 5e7f7e5

Browse files
committed
readme
1 parent 3908371 commit 5e7f7e5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Laravel Asset Helper
2+
3+
This package provides a helper to generate paths to assets on the client-side like you would in Laravel with `asset('foo.jpg')`.
4+
5+
The package can be configured with a mix `.env` variable:
6+
7+
```
8+
ASSET_URL=https://mycdn.net
9+
MIX_ASSET_URL="${ASSET_URL}"
10+
```
11+
12+
Or by adding a meta tag, which is handy if the `ASSET_URL` is determined at deployment time (like with Laravel Vapor):
13+
14+
```html
15+
<meta name="asset-url" content="{{ config('app.asset_url') }}">
16+
```
17+
18+
To inject an asset into a Vuejs component, use a [dynamic prop](https://vuejs.org/v2/guide/components-props.html#Passing-Static-or-Dynamic-Props):
19+
20+
```html
21+
<img :src="asset('path/to/foo.jpg')">
22+
```
23+
24+
This will be prefixed with the asset URL the same as how the Laravel `asset()` helper works.
25+
26+
If you need to conditionally build against a specific environment file, take a look at [mix-env-file](https://github.com/johnwilhite/mix-env-file).

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"laravel",
1515
"mix",
1616
"asset",
17-
"vuejs"
17+
"vuejs",
18+
"vapor",
19+
"dotenv"
1820
],
1921
"author": "Steve Thomas",
2022
"license": "MIT",

0 commit comments

Comments
 (0)