When using tailwind responsive classes (ex: md:my-auto
, focus:ring-0
, focus:outline-none
) in svelte kit component style tags, I get the following error:
500
Semicolon or block is expected
ParseError: Semicolon or block is expected
at error (/var/www/html/node_modules/svelte/compiler.js:16752:20)
at Parser$1.error (/var/www/html/node_modules/svelte/compiler.js:16828:10)
at Object.read_style [as read] (/var/www/html/node_modules/svelte/compiler.js:13141:21)
at tag (/var/www/html/node_modules/svelte/compiler.js:15887:34)
at new Parser$1 (/var/www/html/node_modules/svelte/compiler.js:16787:22)
at parse$3 (/var/www/html/node_modules/svelte/compiler.js:16919:21)
at compile (/var/www/html/node_modules/svelte/compiler.js:30012:18)
at compileSvelte (/var/www/html/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:244:48)
at async TransformContext.transform (/var/www/html/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:837:27)
at async Object.transform (/var/www/html/node_modules/vite/dist/node/chunks/dep-6b5f3ba8.js:44285:30)
Here is the code for my component:
<script>
export let switched = false;
</script>
<button class="switch-button transition-transform transform ease-in-out duration-300" class:-rotate-180={switched}
on:click={()=>{switched = !switched}}>
<span class="text-2xl md:hidden"><i class="fas fa-arrow-down"></i></span>
<span class="text-xl hidden md:inline"><i class="fas fa-arrow-right"></i></span>
</button>
<style lang="postcss" type="text/postcss">
.switch-button {
@apply border-none appearance-none md:my-auto my-2 font-bold text-center rounded-full h-12 w-12 bg-red-500 text-white;
}
.switch-button:focus{
@apply outline-none;
}
.switch-button:active{
@apply bg-red-300;
}
</style>
I'm unsure what's causing this issue in particular. I have a feeling it might just be a svelte-kit bug. I know there are work arounds like using vanilla css for responsiveness instead of tailwind classes, or using an external css files, but I would rather not use those options as I very much like the tailwind classes.
Please let me know if you know what's happening here, or if you need more information regarding my projects environment, please let me know. Thanks in advance!
Link to my projects source code: https://github.com/DriedSponge/GorillianCurrencyConversion
Version information:
- svelte-kit:
1.0.0-next.109
- tailwindcss:
2.1.2
- vite:
2.3.4
(I do have jit enabled on tailwind)