You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Javascript doesn't allow (yet) for conditionally importing modules. This won't work:
if (useBootstrap) {
import 'bootstrap';
}
but importing css files isn't really using javascript, right? There's a preprocessor that reads the css locatation and creates a stylesheet link. So might it be possible for this to be conditional? I'm thinking of the case where only one theme is loaded.
import 'bootstrap/dist/css/bootstrap.min.css';
if (darkTheme) {
import 'bootstrap-dark.min.css';
}
// or
import `bootstrap/dist/css/bootstrap-${theme}.min.css`;
I imagine that this isn't easy to support, because the preprocessing happens before the javascript is executed. So brainstorming, perhaps a conditional import?
Add a bulleted list, <Ctrl+Shift+8>Add a numbered list, <Ctrl+Shift+7>Add a task list, <Ctrl+Shift+l>
Directly mention a user or teamReference an issue or pull request
Add heading textAdd bold text, <Ctrl+b>Add italic text, <Ctrl+i>Add a bulleted list, <Ctrl+Shift+8>Add a numbered list, <Ctrl+Shift+7>Add a task list, <Ctrl+Shift+l>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
{{title}}
-
Javascript doesn't allow (yet) for conditionally importing modules. This won't work:
but importing css files isn't really using javascript, right? There's a preprocessor that reads the css locatation and creates a stylesheet link. So might it be possible for this to be conditional? I'm thinking of the case where only one theme is loaded.
I imagine that this isn't easy to support, because the preprocessing happens before the javascript is executed. So brainstorming, perhaps a conditional import?
Of course, that doesn't feel right, but I figured I'd ask in case there's a way.
Beta Was this translation helpful? Give feedback.
All reactions