-
Notifications
You must be signed in to change notification settings - Fork 51
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
Unable to load CSS in component #24
Comments
You have to pass the styles as a raw string, replace style-loader with raw-loader |
@BlackSonic already tried the raw-loader approach, however the problem comes from the |
Added example for style loading and without |
What I am trying to do is - load a stylesheet that will hold the styling for the whole application, and it is not part of a module. And the Maybe we can open an issue in the Angular repo - if you think that this is related to the offline compiler? |
@KirilNN Added support for global styles. I dont think that using ViewEncapsulation.None for global styles is a good practice. Rather require them in a separate file like now in the examples polyfill.ts. |
@BlackSonic Thanks for that, tested it and it worked perfectly. One side question - with the new setup I am not really sure that AoT works correctly. For example the following setup should throw an error I guess (private variable used in template)?:
Maybe they fixed the compiler in the latest version? However I cannot find any record for it |
It should throw, but i would search for it in the main repository. |
@BlackSonic Have this very same issue:
I might agree it's more elegant to place all global styles in a separate file, but nonetheless this should not happen. I've been investigating this problem a bit, and it's really silly: in the compiled .ngfactory, styles are always accessed like Do you think we should open this to the Angular Team? |
@BlackSonic Particularly, this problem can be identified in the compiler source code: When in a component context, a variable named styles is used to get the exported value. However, that variable only exists when a shim is used, but only happens when ViewEncapsulation is Emulated. Opening a issue :) Cross ref: angular/angular#12775 |
We are trying to load a CSS file into the HelloWorld component using:
this throws with
You may need an appropriate loader to handle this file type.
Tried adding
css-loader
andstyle-loader
in thewebpack.config.js
file:but this triggers an Angular exception
Cannot read property 'replace' of undefined
.Any help will be appreciated!
The text was updated successfully, but these errors were encountered: