Skip to content
main
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

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

Install

npm install @codinglabs/laravel-asset --save

Vue.js example:

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://foo.cloudfront.net
MIX_ASSET_URL="${ASSET_URL}"

Or by adding a meta tag, which is handy if the ASSET_URL is determined at deployment time (like with Laravel Vapor):

<meta name="asset-url" content="{{ config('app.asset_url') }}">

To inject an asset into a Vuejs component, use a dynamic prop:

<img :src="asset('path/to/foo.jpg')">

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.

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.

License

The MIT License (MIT). Please see License File for more information.

About

A simple helper to generate paths to assets in Laravel

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published