middleman / middleman-livereload

LiveReload support for Middleman
http://middlemanapp.com
MIT License
117 stars 39 forks source link

Expose Rack::LiveReload's ignore option. #73

Closed kevincox closed 9 years ago

kevincox commented 9 years ago

Currently there is no way to select which files get the livereload script tag injected in them. This causes problems when you are transmitting html fragments (such as for html imports) and rack tries to insert it's script tag and ends up turning it into a document. If Rack::LiveReload's ignore option was exposed it would be easy to prevent these files from being modified.

Arcovion commented 9 years ago

Is this sufficient? https://github.com/Arcovion/middleman-livereload/commit/9c72eb8297127a5a58c1bb143fb655a6238e26df

Try with: gem 'middleman-livereload', github: 'arcovion/middleman-livereload', branch: 'ignore-option'

I've only done this change through GitHub, no actual testing...

kevincox commented 9 years ago

I believe you also have to pass it to livereload here.

kevincox commented 9 years ago

You are so fast I barely had time to implement my quick, ugly workaround but I'll post it here in case it is useful.

    activate :livereload
    ready do
        self.class.instance_variable_get(:@middleware)[-1][1][0][:ignore] = [
            %r(^/assets/),
            # Other ignore paths.
        ]
    end

Ensure that you add the block right after activating livereload.

kevincox commented 9 years ago

Thanks! Works perfectly.