admin管理员组文章数量:1358165
I need to import "desktop.scss" or "mobile.scss" in my astro "MainComponent".
So, based on ternary I have string "Desktop" or "Mobile" but when I try to import it, it always import both scss's.
First I tried:
import `../styles/${device}.scss`;
But I can't pass variable to import css.
Then I put scss import in 2 components: Desktop.astro and Mobile.astro which only job is to import scss:
import '../../styles/desktop.scss'
And Mobile.astro:
import '../../styles/mobile.scss'
Then in my MainComponent I tried:
const device = isMobile ? "Mobile" : "Desktop"
import(`../components/css/${device}.astro`)
It imports both scss files :(
Any idea?
I need to import "desktop.scss" or "mobile.scss" in my astro "MainComponent".
So, based on ternary I have string "Desktop" or "Mobile" but when I try to import it, it always import both scss's.
First I tried:
import `../styles/${device}.scss`;
But I can't pass variable to import css.
Then I put scss import in 2 components: Desktop.astro and Mobile.astro which only job is to import scss:
import '../../styles/desktop.scss'
And Mobile.astro:
import '../../styles/mobile.scss'
Then in my MainComponent I tried:
const device = isMobile ? "Mobile" : "Desktop"
import(`../components/css/${device}.astro`)
It imports both scss files :(
Any idea?
Share Improve this question edited Apr 1 at 8:17 Gnesh asked Apr 1 at 8:03 GneshGnesh 451 silver badge11 bronze badges1 Answer
Reset to default 0Pretty sure this is done when you build the website. At that point you don't know whether any given user will be on mobile or desktop.
What you're looking for is CSS media queries.
本文标签: reactjsUse dynamic import for SCSS in ASTROStack Overflow
版权声明:本文标题:reactjs - Use dynamic import for SCSS in ASTRO - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743901197a2558705.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论