svelte-vars

0.1.0 • Public • Published

Eyeballs tripping up over a couple of dollar signs? Do you exclusively use const and let in your code? Have a play with this.

To get started, here's an example of what your svelte.config.js file might look like when using this plugin in a SvelteKit project:

import { svelteVars } from 'svelte-vars'
export default {
	preprocess: [ svelteVars(), vitePreprocess() ],
	kit: { adapter: adapter() }
}

And within your Svelte components, you can now do the following:

<script lang="ts">
    let value = 0;
    // $: doubled = value * 2;
    var doubled = value * 2;
    const increment = () => val = val + 1
</script>

<button on:click={increment}>{doubled}</button>

Package Sidebar

Install

npm i svelte-vars

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

3.06 kB

Total Files

3

Last publish

Collaborators

  • emmyarty