Manage Assets with Laravel Mix on Package How to manage assets inside a package with laravel mix?
When you compile down your assets you just need to reference this assets in your view. If your assets are versioned, you can use the mix() helper to point to the versioned assets automatically:
<script src="{{ mix('/js/app.js') }}"></script>
Docs for compiling assets with mix: https://laravel.com/docs/5.7/mix
I know how to use mix from root of project. But I want to use from my custom package, that I have inside packages/vendorname/packagename
@ZOROASTER - You don't need laravel-mix for a laravel package. You want laravel-mix just for the package development when compiling assets.
If you don't want your users to overwrite the files you can just have the compiled files in your package.
If you want your users to overwrite the assets, let them publish the assets and do what they want. Docs: https://laravel.com/docs/5.7/packages#public-assets
public function boot()
{
$this->publishes([
__DIR__.'/path/to/assets' => public_path('vendor/courier'),
], 'public');
}
I found what I looking for.
/// Load mix and mix-merge-manifest
const { mix } = require('laravel-mix');
require('laravel-mix-merge-manifest');
/// Allow merge manifest
mix.setPublicPath('../../public').mergeManifest();
Please sign in or create an account to participate in this conversation.