In the readme’s of packages you’ll often find an instruction like this to publish it’s assets:
php artisan vendor:publish
To avoid this you should always add the
provider-option pointing to your service provider. The publish command will then only publish the assets of your package. Here’s an example taken from our backup package:
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"
You can even use tags to create groups of assets. Here’s an example taken from the readme of our laravel-googletagmanager package to only publish the config file (and not the view files).
php artisan vendor:publish --provider="Spatie\GoogleTagManager\GoogleTagManagerServiceProvider" --tag="config"
Such a group can be created by using the second parameter of the
publishes-function in a serviceProvider. Here’s the relevant code taken for the service provider of the aforementioned package.
$this->publishes([ __DIR__.'/../resources/config/config.php' => config_path('googletagmanager.php'), ], 'config'); $this->publishes([ __DIR__.'/../resources/views' => base_path('resources/views/vendor/googletagmanager'), ], 'views');