Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
stevethomas committed Sep 10, 2019
1 parent a5241b6 commit 0960a4d
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# Laravel Asset Helper
This package provides a helper to generate paths to assets on the client-side the same as in Laravel with `asset('foo.jpg')`.

This package provides a helper to generate paths to assets on the client-side like you would in Laravel with `asset('foo.jpg')`.
## Install
``` bash
npm install @codinglabs/laravel-asset --save
```

Vue.js example:
``` javascript
import {asset} from '@codinglabs/laravel-asset'

window.Vue = require('vue')

Vue.mixin({
methods: {
asset: asset
}
})
```

## Usage
The package can be configured with a mix `.env` variable:

```
ASSET_URL=https://mycdn.net
ASSET_URL=https://foo.cloudfront.net
MIX_ASSET_URL="${ASSET_URL}"
```

Expand All @@ -15,6 +33,7 @@ Or by adding a meta tag, which is handy if the `ASSET_URL` is determined at depl
<meta name="asset-url" content="{{ config('app.asset_url') }}">
```


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):

```html
Expand All @@ -24,3 +43,9 @@ To inject an asset into a Vuejs component, use a [dynamic prop](https://vuejs.or
This will be prefixed with the asset URL the same as how the Laravel `asset()` helper works.

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).

## About Coding Labs
Coding Labs is a web app development agency based on the Gold Coast, Australia. See our open source projects [on our website](https://codinglabs.io).

## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.

0 comments on commit 0960a4d

Please sign in to comment.