package.json
{
"name": "steal-element",
"version": "0.0.1",
"description": "StealJS Element to dedublicate Steal Loading and other optimizations",
"main": "steal-element.js",
"repository": "https://github.com/at-nikolaus/steal-element",
"author": "Frank Lemanschik <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"steal": "^1.6.0"
},
"devDependencies": {
"steal-tools": "^1.9.2"
}
}
import.html from import-relativ-self.html
create folder steal-element cd steal-element yarn init yarn add steal create import.html
<html><head>
<script type="text/javascript">
let ownerDocument = document.currentScript.ownerDocument
let baseUrl = ownerDocument.location.pathname.split('import.html')[0]
let base = document.createElement('base')
base.href = baseUrl
ownerDocument.head.appendChild(base)
</script>
<!-- here base gets attached -->
</head><body>
<link rel="import" src="steal-element/import.html">
<script>
// Setting the base Url for this document
let base = document.currentScript.ownerDocument.querySelector('base')
if (base) {
steal.config({
baseURL: base.href+"../libs" // document.createElement('base').href
});
}
steal.import(my-lib)
</script>
</body></html>