Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessor only looks for imports in the first <script> tag if multiple are present #818

Closed
bryanswanpm opened this issue Mar 10, 2022 · 1 comment · Fixed by #819
Closed

Comments

@bryanswanpm
Copy link

Sveltekit components may have multiple <script> tags, and unless .mcss files are imported within the first tag, the preprocessor will fail to find the references and won't compile the associated styles:

Fails:

<script context="module">
	export const prerender = true;
</script>

<script>
	import Component from '$lib/Component.svelte';
	
        import css from "$lib/fooga/fooga.mcss";
</script>

<div class="{css.fooga}">Lorum Ipsum</div>

Works:

<script context="module">
	import css from "$lib/fooga/fooga.mcss";

	export const prerender = true;
</script>

<script>
	import Component from '$lib/Component.svelte';
</script>

<div class="{css.fooga}">Lorum Ipsum</div>
tivac added a commit that referenced this issue Mar 10, 2022
At least until a matching import is found, still bail on the first one for optimization simplicity reasons.

Fixes #818
tivac added a commit that referenced this issue Mar 11, 2022
* feat(svelte): check every <script>

At least until a matching import is found, still bail on the first one for optimization simplicity reasons.

Fixes #818
@tivac
Copy link
Owner

tivac commented Mar 11, 2022

Fix released as @modular-css/svelte@28.1.0, thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants