Created
July 26, 2022 12:06
-
-
Save fgeierst/4a36e80e9086ce5312e1c99a069bd41d to your computer and use it in GitHub Desktop.
Islands architecture with TYPO3+Rollup+Svelte
This file contains hidden or 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
import Test from './Test.svelte'; | |
// Mount Svelte component | |
const test = new Test({ | |
target: document.querySelector('#test') | |
}); |
This file contains hidden or 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
import svelte from 'rollup-plugin-svelte'; | |
import css from 'rollup-plugin-css-only' | |
import { terser } from 'rollup-plugin-terser'; | |
import { nodeResolve } from '@rollup/plugin-node-resolve'; | |
export default { | |
input: { | |
Main: 'packages/svelte_demo/Resources/Private/JavaScript/Main.js', | |
}, | |
output: { | |
dir: 'packages/svelte_demo/Resources/Public/JavaScript/', | |
format: 'iife', | |
}, | |
plugins: [ | |
nodeResolve(), | |
css({ output: 'rollup.css' }), | |
svelte({ | |
// Emit CSS as "files" for other plugins to process. default is true | |
emitCss: true, | |
}), | |
terser(), | |
], | |
}; |
This file contains hidden or 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
<script> | |
let promise = fetch('/api').then((x) => x.json()); | |
</script> | |
<div> | |
<h2>Hello Svelte Component</h2> | |
{#await promise} | |
<!-- show something while promise is pending --> | |
<p>Loading...</p> | |
{:then data} | |
<!-- promise was fulfilled --> | |
<p> | |
{@html data.content.colPos0[0].content.bodytext} | |
</p> | |
{:catch error} | |
<!-- show something while promise was rejected --> | |
<p>Something went wrong.</p> | |
{/await} | |
</div> | |
<style> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment