vladshcherbin/rollup-plugin-svelte-static-html(opens in a new tab)
Language: JavaScript
Generate static html file from your Svelte component using Rollup
- stars
- 19
- watchers
- 1
- forks
- 2
- open issues
- 1
- Last updated
- 09/07/2021
Language: JavaScript
Generate static html file from your Svelte component using Rollup
Generate static html file from your Svelte component using Rollup.
# yarn yarn add rollup-plugin-svelte-static-html -D # npm npm install rollup-plugin-svelte-static-html -D
// rollup.config.js import svelteStaticHtml from 'rollup-plugin-svelte-static-html' export default { input: 'src/index.js', output: { file: 'dist/app.js', format: 'iife' }, plugins: [ svelteStaticHtml({ component: 'src/App.svelte', output: 'dist/index.html', template: 'src/assets/template.html' }) ] }
There are some useful options:
Type: string
Path to the component from which html is generated.
svelteStaticHtml({ component: 'src/App.svelte' })
Type: string
Path for the generated html file.
svelteStaticHtml({ component: 'src/App.svelte', output: 'dist/index.html' })
Type: string
Path to the template to use. When not set, only component html is saved.
svelteStaticHtml({ component: 'src/App.svelte', output: 'dist/index.html', template: 'src/assets/template.html' })
Type: string | Default: body
Selector to append generated component html to. Can be a tag, a class or an id. Only used only when template is set.
svelteStaticHtml({ component: 'src/App.svelte', output: 'dist/index.html', template: 'src/assets/template.html', selector: '#widget' })
Type: object
Properties to pass to the component.
svelteStaticHtml({ component: 'src/App.svelte', output: 'dist/index.html', props: { name: 'Jack' } })
Type: boolean | Default: false
Add component css to the top of generated html or append to head if template is set.
svelteStaticHtml({ component: 'src/App.svelte', output: 'dist/index.html', inlineCss: true })
Type: array | object
Preprocess the component. By default, svelte-preprocess is used in auto mode.
svelteStaticHtml({ component: 'src/App.svelte', output: 'dist/index.html', preprocess: [ scss(), pug() ] })
MIT