laravel
laravel copied to clipboard
Laravel Mix Support
Is there built-in support for Laravel Mix?
If not, is there a recommended way to run npm run production?
To be honest, this package used to contain a dependency on https://github.com/capistrano/npm I believe. I removed it because it was always buggy for us.
You could try adding it separately and see how your results may fare. It seems it hasn’t had any update in 2 years, so I’m unsure if anything has changed there.
I wouldn’t be against trying to figure out a solution as it’s something I’m also interested in.
Not sure which approach is better - deploying the generated files or generating them on the target server with Laravel Mix.
What I did to generate them on the server was:
- Added
require "capistrano/npm"inCapfile - Defined a new task in
deploy.rb
namespace :laravel do
desc "Laravel Mixing..."
task :mix do
on roles(:all) do
execute "cd #{current_path} && npm run prod"
end
end
end
- Called the newly defined task in
deploy.rb
namespace :deploy do
after :published, "laravel:mix"
end
Do you see anything wrong in this approach? I am new to Capistrano, so any feedback will be appreciated.
You'd want to run it before the published stage as if it's already symlinked to current, that means the site should be live/ready to access.