spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Add a property for configuring additional livereload paths

Open meta-forte opened this issue 1 year ago • 7 comments

Thymeleaf allows using files from src folder during development. However live reload does not have a file system watcher for "additional paths" to auto reload based on those templates

Just as there is there is spring.devtools.restart.additional-paths,

request new property spring.devtools.livereload.additional-paths

this should work in support of thymeleaf.prefix

logging:
  config: classpath:log4j2-local.xml
spring:
  devtools:
    livereload:
      enabled: 'true'
      additional-paths:
        - file:src/main/resources/static/
        - file:src/main/resources/templates/
  thymeleaf:
    cache: 'false'
    prefix: file:src/main/resources/templates/
    check-template-location: 'true'

  web:
    resources:
      static-locations:
        - file:src/main/resources/static/
        - classpath:/static/
      cache:
        period: 0

meta-forte avatar Apr 13 '24 03:04 meta-forte

I think this is already possible, but it's somewhat non-intuitive:

Add the additional paths to spring.devtools.restart.additional-paths but then exclude them from restarting the application through spring.devtools.restart.additional-exclude.

This should set the filewatcher to watch for changes, triggering the livereload, but don't restart the app as the location has been excluded from restart.

But I agree that there should be a property for that.

mhalbritter avatar Apr 17 '24 14:04 mhalbritter

Hi @mhalbritter ,

I would like to work on this enhancement, could you please assign me this issue so that I can submit my PR in favour of this issue.

Thanks, Akshay

itsAkshayDubey avatar May 21 '24 00:05 itsAkshayDubey

All yours @itsAkshayDubey

philwebb avatar May 21 '24 01:05 philwebb

I used a work-around and achieved this behavior

see LiveReloadConfig.java in this repo https://github.com/ibhatech/world-facts/tree/dev

meta-forte avatar May 21 '24 16:05 meta-forte

Unable to access this repo. @metaforte

itsAkshayDubey avatar May 21 '24 16:05 itsAkshayDubey

made it public now

meta-forte avatar May 21 '24 17:05 meta-forte

Hi @philwebb ,

Kindly have a look at PR #41566

Thanks, Akshay

itsAkshayDubey avatar Jul 20 '24 12:07 itsAkshayDubey