-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement/issue 354 restore optimization config for no bundle (#477)
* client side router optimization setting for build * filter only for anchor tags * preserve URL on route change * mode vs optimization configuration * test cases for MPA * clean up merge conflict marker * clarify test it statements * fix bug with graphql head tag closing * default optimization for preloading CSS * only preload CSS * add none optimization option * all anticipated optimization settings * simplify minified output check * added static optimization setting for JS templating * introduce inline optimization setting * inline optimization support enhancements * fix styling for tables * documentation for mode and optimization * use modulepreload for ESM script tags
- Loading branch information
1 parent
1d23bbe
commit 16e19dd
Showing
51 changed files
with
1,153 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* eslint-disable no-underscore-dangle */ | ||
document.addEventListener('click', function(e) { | ||
e.preventDefault(); | ||
|
||
if (e.path[0].href) { | ||
console.debug('linked clicked was...', e.path[0].href); | ||
const target = e.path[0]; | ||
const route = target.href.replace(window.location.origin, ''); | ||
const routerOutlet = Array.from(document.getElementsByTagName('greenwood-route')).filter(outlet => { | ||
return outlet.getAttribute('data-route') === route; | ||
})[0]; | ||
|
||
console.debug('routerOutlet', routerOutlet); | ||
|
||
if (routerOutlet.getAttribute('data-template') === window.__greenwood.currentTemplate) { | ||
window.__greenwood.currentTemplate = routerOutlet.getAttribute('data-template'); | ||
routerOutlet.loadRoute(); | ||
} else { | ||
console.debug('new template detected, should do a hard reload'); | ||
window.location.href = target; | ||
} | ||
} | ||
}); | ||
|
||
class RouteComponent extends HTMLElement { | ||
loadRoute() { | ||
const route = this.getAttribute('data-route'); | ||
const key = this.getAttribute('data-key'); | ||
console.debug('load route ->', route); | ||
console.debug('with bundle ->', key); | ||
fetch(key) | ||
.then(res => res.text()) | ||
.then((response) => { | ||
history.pushState(response, route, route); | ||
document.getElementsByTagName('router-outlet')[0].innerHTML = response; | ||
}); | ||
} | ||
} | ||
|
||
class RouterOutletComponent extends HTMLElement { } | ||
|
||
customElements.define('greenwood-route', RouteComponent); | ||
customElements.define('router-outlet', RouterOutletComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.