File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 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 ) .
Original file line number Diff line number Diff line change 1414 " laravel" ,
1515 " mix" ,
1616 " asset" ,
17- " vuejs"
17+ " vuejs" ,
18+ " vapor" ,
19+ " dotenv"
1820 ],
1921 "author" : " Steve Thomas" ,
2022 "license" : " MIT" ,
You can’t perform that action at this time.
0 commit comments