middleman-deploy
middleman-deploy copied to clipboard
Don't run livereload when deploying.
When I run 'middleman deploy', it seems to run LiveReload when I use middleman-livereload in a project.
Could you paste a copy of your config.rb here please?
require "json"
require "slim"
require "coffee-script"
require "uglifier"
Slim::Engine.set_default_options :pretty => true
Time.zone = "Pacific Time (US & Canada)"
set :css_dir, 'css'
set :js_dir, 'js'
set :images_dir, 'images'
set :fonts_dir, 'fonts'
set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true,
:autolink => true,
:smartypants => true
page "humans.txt", :layout => false
page "robots.txt", :layout => false
page "/errors/404.html", :layout => false
activate :directory_indexes
activate :livereload
class FixPermissions < Middleman::Extension
def initialize(app, options_hash={}, &block)
super
app.after_build do |builder|
builder.run 'chmod 644 build/images/*'
builder.run 'chmod 644 build/css/*'
builder.run 'chmod 644 build/js/*'
end
end
end
::Middleman::Extensions.register(:fix_perm, FixPermissions)
configure :build do
# Prep Assets for Caching
activate :asset_hash
activate :asset_host
set :asset_host, "//cdn.rbg.io"
# Minify Text
activate :minify_css
activate :minify_javascript
# Compress Images
activate :imageoptim
# Fix Permissions
activate :fix_perm
end
activate :deploy do |deploy|
#deploy.build_before = true
deploy.method = :rsync
deploy.clean = true
deploy.user = ""
deploy.port =
deploy.host = ""
deploy.path = ""
end
Thanks!
Hm. Any idea how the "build" method turns that off? Or does it run during that too?
It doesn't run during the build method. Unfortunately, I have no idea how it works, though.
I'm running into the same thing.
Maybe you need to talk to the middleman-livereload guy to have it not run if it's not :development rather than if build don't do anything.
https://codeclimate.com/github/middleman/middleman-livereload/Middleman::LiveReloadExtension
Supposedly this has been resolved by https://github.com/middleman/middleman-livereload/issues/41. Can someone else confirm this? Thanks @roundedbygravity !
I updated my middleman-livereload gem and I'm still seeing it on deploy. Others seem to also:
https://github.com/middleman/middleman-livereload/issues/41
I've even changed my config to call it this way and no dice:
configure :development do activate :livereload end
With middleman-core (3.2.2)
and middleman-livereload (3.2.1)
, even wrapping the LiveReload activation in a configure :development
block still runs LiveReload during deployment.
I am seeing the same issue, anyone find a way to fix this
Same problem here
I'm creating an extension to auto-open a browser window to the live reload URL in dev, and I'm seeing the same thing for my extension that you guys see for live reload. I even check to make sure the environment isn't the dev environment out of paranoia and the browser is still opened twice. (doing all the right things like only activating the plugin during dev, etc). Similar to live reload, I don't see this issue occurring during the build command, only during the deploy command.
Snipit of my paranoia:
app.ready do |builder|
return unless app.environment == :development
Launchy.open("http://0.0.0.0:4567")
end
I get the same thing and my activate :livereload is declared within a configure :development do
block inside my config.rb. Commenting it out got around the issue but it's not ideal
Having a similar problem when trying to access Middleman::PreviewServer properties in the development
configuration block.
By the looks of it, this is due to how options are retrieved through Middleman Deploy's CLI.
https://github.com/middleman-contrib/middleman-deploy/blob/master/lib/middleman-deploy/commands.rb#L62
options = ::Middleman::Application.server.inst.options
::Middleman::Application.server.inst
then triggers
mm.run_hook :ready
Which will trigger the configuration block.
I'm kind of new to Ruby so I haven't looked into actually fixing it but this ticket in Middleman's repo may be relevant: https://github.com/middleman/middleman/issues/781
Here's my stacktrace:
/home/jahed/projects/jahed-io/site/config.rb:26:in `block in initialize': uninitialized constant Middleman::PreviewServer (NameError)
from /home/jahed/.gem/ruby/gems/uber-0.0.13/lib/uber/options.rb:80:in `instance_exec'
from /home/jahed/.gem/ruby/gems/uber-0.0.13/lib/uber/options.rb:80:in `proc!'
from /home/jahed/.gem/ruby/gems/uber-0.0.13/lib/uber/options.rb:69:in `evaluate_for'
from /home/jahed/.gem/ruby/gems/uber-0.0.13/lib/uber/options.rb:60:in `evaluate'
from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:53:in `execute_callback'
from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:40:in `block in run'
from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:39:in `each'
from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:39:in `inject'
from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/hook.rb:39:in `run'
from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks.rb:55:in `run_hook_for'
from /home/jahed/.gem/ruby/gems/hooks-0.4.0/lib/hooks/instance_hooks.rb:6:in `run_hook'
from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/core_extensions/extensions.rb:166:in `initialize'
from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/core_extensions/data.rb:33:in `initialize'
from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/application.rb:204:in `initialize'
from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/core_extensions/request.rb:56:in `new'
from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/core_extensions/request.rb:56:in `inst'
from /home/jahed/.gem/ruby/gems/middleman-deploy-1.0.0/lib/middleman-deploy/commands.rb:62:in `deploy_options'
from /home/jahed/.gem/ruby/gems/middleman-deploy-1.0.0/lib/middleman-deploy/commands.rb:36:in `build_before'
from /home/jahed/.gem/ruby/gems/middleman-deploy-1.0.0/lib/middleman-deploy/commands.rb:29:in `deploy'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/cli.rb:72:in `method_missing'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/command.rb:29:in `run'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/command.rb:126:in `run'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /home/jahed/.gem/ruby/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/lib/middleman-core/cli.rb:20:in `start'
from /home/jahed/.gem/ruby/gems/middleman-core-3.3.12/bin/middleman:18:in `<top (required)>'
from /home/jahed/bin/middleman:23:in `load'
from /home/jahed/bin/middleman:23:in `<main>'
Does activate :livereload
need to be moved into a :development configuration?
configure :development do
activate :livereload
end
@robertwbradford We're doing that already. You can find the config.rb
we're using here:
https://github.com/unruly/unruly.github.io/blob/develop/config.rb