capistrano / laravel

Gem for deploying Laravel projects with capistrano v3.*
MIT License
222 stars 71 forks source link

Laravel Mix Support #44

Open o15a3d4l11s2 opened 6 years ago

o15a3d4l11s2 commented 6 years ago

Is there built-in support for Laravel Mix? If not, is there a recommended way to run npm run production?

ikari7789 commented 6 years ago

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.

o15a3d4l11s2 commented 6 years ago

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:

  1. Added require "capistrano/npm" in Capfile
  2. 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
  3. 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.

ikari7789 commented 6 years ago

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.