-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
[Feature request]: Enable loading css resources from view model #132
Comments
First thing to check when it comes to loading CSS with Aurelia: are your loaders properly configured? If answer is yes, it would be nice to provide a few details on the error you get or what is actually happening. Generally speaking, there is no special considerations for this in Webpack plugin, so apart from your configuration there's a good chance that problems stem from the runtime. |
Hmm @bigopon can you clarify the difference with this approach and import './xxx.css' |
For following comparison: In a custom element view, we can require css <template>
<require from='some.css'></require>
</template> Now if we do the same thing in custom attribute, it would be consistent, the way we load css resources. There is no issue with |
@bigopon so to summarize it's kinda syntactic sugar. Right? no difference in produced result. I.e. css is not scoped shadowDommed.. or anything? |
kind of no. but we can always do some more work to scope it , if need be. |
well |
well, actually, i just checked if that would be possible. so, there would be some demand edit1: $view= `<template>
<require from='./xy.css'></require>
... nor @inlineView(`<template>
<require from='./xy.css'></require>
... works 😒 edit2: |
I am closing this as there is no "feature" to add here. Basically, this is about configuring your CSS loaders properly. Note that if you use the suggested config: rules: [
{
test: /\.css$/i,
loader: 'css-loader',
issuer: /\.html?$/i
},
{
test: /\.css$/i,
loader: ['style-loader', 'css-loader'],
issuer: /\.[tj]s$/i
}
] Then it won't work because when the issuer is import "style.css";
export class VM {} But if you use @viewResources(PLATFORM.moduleName("style.css"))
export class VM { } Then Aurelia is loading your CSS, even though it is references in a Webpack provides many tools to control which loaders are applied in different situations. You need to play with that so that CSS loaders are applied in a way that matches how you use them. For example, if you never import CSS directly and always go through Aurelia (either with rules: [
{
test: /\.css$/i,
loader: 'css-loader',
},
] This simple config will work for the code by OP. If you have CSS imports in your |
At the moment, doing the following is not working
This is for aurelia/templating#581
The text was updated successfully, but these errors were encountered: