Skip to content

Commit 3f057a8

Browse files
committed
revert to Laravel Mix instructions
1 parent ab27312 commit 3f057a8

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Laravel Asset Helper
22
This package provides a helper to generate paths to assets on the client-side the same as in Laravel with `asset('foo.jpg')`.
33

4+
Notices:
5+
- This package works best with Laravel Mix; if you are using Vite, you should [bundle assets](https://laravel.com/docs/9.x/vite#blade-processing-static-assets) in the `resources` directory instead
6+
- There is also an official asset helper for [Laravel Vapor](https://docs.vapor.build/1.0/projects/deployments.html#asset)
7+
48
## Install
59
``` bash
610
npm install @codinglabs/laravel-asset --save
@@ -39,7 +43,7 @@ To configure with an `.env` variable:
3943

4044
```
4145
ASSET_URL=https://foo.cloudfront.net
42-
VITE_ASSET_URL="${ASSET_URL}"
46+
MIX_ASSET_URL="${ASSET_URL}"
4347
```
4448

4549
To configure with a meta tag in Laravel Blade:

asset.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export const asset = (path) => {
2-
// default to VITE_ASSET_URL
3-
let prefix = import.meta.env.VITE_ASSET_URL
2+
// default to MIX_ASSET_URL
3+
let prefix = process.env.MIX_ASSET_URL
44

5-
if (!prefix) {
6-
// fallback to determining ASSET_URL from meta tag
7-
prefix = document.head.querySelector('meta[name="asset-url"]').content
8-
}
5+
if (!prefix) {
6+
// fallback to determining ASSET_URL from meta tag
7+
prefix = document.head.querySelector('meta[name="asset-url"]').content
8+
}
99

10-
return prefix.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, '')
10+
return prefix.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, '')
1111
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": false,
33
"name": "@codinglabs/laravel-asset",
4-
"version": "2.0.1",
4+
"version": "1.0.4",
55
"description": "A helper to resolve paths to assets in a Laravel app",
66
"main": "asset.js",
77
"repository": {

0 commit comments

Comments
 (0)