tineikt/xp-lib-browsersync


Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.tineikt:xp-lib-browsersync:1.0'
	}
	dependencies {
		implementation("com.github.tineikt:xp-lib-browsersync:1.0")
	}
	<dependency>
	    <groupId>com.github.tineikt</groupId>
	    <artifactId>xp-lib-browsersync</artifactId>
	    <version>1.0</version>
	</dependency>

                            
    libraryDependencies += "com.github.tineikt" % "xp-lib-browsersync" % "1.0"
        
        

                            
    :dependencies [[com.github.tineikt/xp-lib-browsersync "1.0"]]
        
        

Readme


lib-browsersync

Listen for node events (creating, updating and deleting) from Enonic XP and trigger a browsersync reload if server is running with dev flag

Usage

Deploy to your your Enonic XP installation.

Then start the server with the dev flag (Enonic XP Development mode)

You will quite obviously also need to have browsersync up and running.

Example

Install Browsersync from npm using: npm install -g browser-sync

Start Browsersync proxying Enonic. browser-sync start --proxy 'localhost:8080'

Navigate to your project page or preview with something like this: http://localhost:3000/admin/portal/preview/draft/sitename

Do a change on the content and Browsersync will perform a reload of the page.

Pro tip

Make Browsersync watch files aswell, it will then hotreload resources that it can and otherwise perform a full reload keeping the scroll position. This works great when chaning templates!

This example listens for changes in your projects assets directory, schemas, controllers and templates (Freemarker):

browser-sync start --proxy 'localhost:8080' --files 'src/**/assets/**/*.css' 'src/**/assets/**/*.js' 'src/**/*.ftl' 'src/**/*.xml' 'src/**/*.js'