Webpacker: Deploying a --skip-sprockets app w/ capistrano

Created on 25 May 2017  路  5Comments  路  Source: rails/webpacker

adding capistrano/rails/assets results in an error since rake doesn't know how to build the assets:precompile task without sprockets.

leaving the task out means it can't be enhanced with webpacker:compile.

The readme states: " If you are not using sprockets you can manually trigger bundle exec rails webpacker:compile during your app deploy."

I tried this:

namespace :deploy do
  desc 'Initial Deploy'
  task :initial do
    on roles(:app) do
      before 'deploy:restart', 'puma:start'
      invoke 'deploy'
    end
  end

  task :compile_assets do
    Rake::Task["webpacker:compile"].invoke
  end

  after  :finishing,    :compile_assets
  after  :finishing,    :cleanup
end

also

task :compile_assets do
    on roles(:app) do
      Rake::Task["webpacker:compile"].invoke
    end
  end

but I get "Don't know how to build task 'webpacker:compile'"

What am I doing wrong?

Considering webpacker is capable of completely replacing sprockets, relying on sprockets for deploy seems odd.

enhancement help wanted

Most helpful comment

Just to confirm, adding sprockets fixes everything. I'd love to be able to deploy w/o relying on sprockets.

All 5 comments

@Jascha-Sundaresan Agree but webpacker is still new and we want to support both worlds for now.

Looks like the problem here is capistrano can't find webpacker:compile task. Please try this:

# deploy.rb or Capfile
spec = Gem::Specification.find_by_name 'webpacker'
load "#{spec.gem_dir}/lib/tasks/webpacker/compile.rake"

Perhaps we should provide a hook for capistrano.

Clearly, I must be doing something wrong here...

NameError: uninitialized constant Webpacker
/Users/jsundare/.rvm/gems/ruby-2.4.1@rails510/gems/webpacker-1.2/lib/webpacker/file_loader.rb:2:in `<top (required)>'
/Users/jsundare/.rvm/gems/ruby-2.4.1@rails510/gems/webpacker-1.2/lib/webpacker/env.rb:2:in `require'
/Users/jsundare/.rvm/gems/ruby-2.4.1@rails510/gems/webpacker-1.2/lib/webpacker/env.rb:2:in `<top (required)>'
/Users/jsundare/.rvm/gems/ruby-2.4.1@rails510/gems/webpacker-1.2/lib/tasks/webpacker/compile.rake:1:in `require'
/Users/jsundare/.rvm/gems/ruby-2.4.1@rails510/gems/webpacker-1.2/lib/tasks/webpacker/compile.rake:1:in `<top (required)>'
config/deploy.rb:24:in `load'
config/deploy.rb:24:in `<top (required)>'

Just to confirm, adding sprockets fixes everything. I'd love to be able to deploy w/o relying on sprockets.

any word on providing a capistrano hook?

No current plans to provide one in the box. But feel free to open a issue/PR on the Capistrano site about the topic 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

naps62 picture naps62  路  3Comments

amandapouget picture amandapouget  路  3Comments

ytbryan picture ytbryan  路  3Comments

ilrock picture ilrock  路  3Comments

ankitrg picture ankitrg  路  3Comments