Skip to content

Laravel Mix plugin to run 'php artisan vendor:publish' by chaining '.publish()'

License

Notifications You must be signed in to change notification settings

mzur/laravel-mix-artisan-publish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Mix Artisan Publish

This extension allows you to automatically publish your assets with php artisan vendor:publish with Laravel Mix. This is especially useful if you develop a package in the vendor directory and want to push updated assets to the main application.

Usage

You can install the package with npm via the GitHub package registry. First, in the directory of your package.json run:

echo "@mzur:registry=https://npm.pkg.github.com" >> .npmrc

Then run:

npm install --save-dev @mzur/laravel-mix-artisan-publish

Then require the extension in your Mix configuration:

const mix = require('laravel-mix');

require('@mzur/laravel-mix-artisan-publish');
...

Enable the extension by calling .publish() at the end of your Mix chain:

mix.sass('resources/sass/app.scss', 'public/css').publish();

This will call the artisan vendor:publish command of the main application.

To restrict publishing to a specific provider and/or tag, you may pass an object to .publish(). You can also customize the relative path to the artisan file or disable the --force argument:

mix.sass('resources/sass/app.scss', 'public/css').publish({
   provider: 'My\\Package\\MyPackageServiceProvider',
   tag: 'public',
   path: '../../../artisan',
   force: false,
});

And you're done!

Credits

The structure of this plugin was adapted from laravel-mix-artisan-serve.

About

Laravel Mix plugin to run 'php artisan vendor:publish' by chaining '.publish()'

Resources

License

Stars

Watchers

Forks

Packages