hiddentao / gulp-server-livereload

Gulp plugin to run a local webserver with livereload enabled via socket.io. Also comes with standalone command-line interface.
MIT License
93 stars 28 forks source link

Cannot livereload with pdf files #2

Closed raywang945 closed 9 years ago

raywang945 commented 9 years ago

I am trying to use gulp-server-liverelad to live reload pdf files, but it doesn't work. My gulpfile.coffee:

gulp        = require 'gulp'
shell       = require 'gulp-shell'
server      = require 'gulp-server-livereload'

gulp.task 'tex', ->
    gulp.src('tex/*.tex', read: false)
        .pipe(shell [
            'pdflatex -output-directory build <%= file.path %>'
        ])

gulp.task 'server', ->
    gulp.src('build')
        .pipe(server(
            livereload: false
            directoryListing: false
            defaultFile: 'test.pdf'
            open: false
            port: 1234
        ))

gulp.task 'watch', ['tex', 'server'], ->
    gulp.watch('tex/*.tex', ['tex'])

gulp.task 'default', ['tex']

Chrome cannot load pdf files unless setting livereload to false, is it possible to livereload pdf files?

hiddentao commented 9 years ago

How are you accessing the PDF file in the browser? The livereload plugin assumes you're serving up HTML.

raywang945 commented 9 years ago

I usually view pdf files on Chorme, and it is the default pdf viewer when I click on pdf links on web pages. However, you guide me to think of the actual pdf viewer for Chrome, and it's a Chrome plugin which can be found at chrome://plugins. I think the issue may relate to the pdf viewer plugin.

hiddentao commented 9 years ago

Well the issue is simple.

The livereload plugin usually injects code into the HTML pages it serves - this code ensures that the pages auto-reload within the browser when the files on disk have changed. With the PDF viewer this wouldn't be possible - so unless you're directly viewing the built output PDF and the viewer supports auto-reloading of a changed file it's not going to aut-reload.

raywang945 commented 9 years ago

Yeah, thank you for your answer!