-
Notifications
You must be signed in to change notification settings - Fork 12k
ng build/serve --prod ignores scss url imports if angular.json contains more than 1 style file #10855
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
Comments
I've managed to narrow the issue down. The issue only reproduces if we have more than one non-empty file in In my case, it's:
|
I'm having the same issue. "styles": [ but none of them get loaded. |
Same issue here trying to import google fonts to use with mat-typography. My angular.json includes my styles as well as primeng. I first saw this in our build (where we had the --prod flag). When I add --prod to I worked around it by importing the primeng css in my styles.scss. 👎 |
Was just about to confirm that error - but it turned out I accidentely inserted the styles in the test section of the angular.js file instead of the build section above! Hope this might help someone in the future with the same problem. |
Meet the issue too: In styles.scss
In angular.json
Roboto font work with |
I have the same issue:
None of these imports are working when using
|
I have the exact same issue. Multiple styles added in angular.json, and the google font import in my scss files are not in the output css. importing the css files of my package.json directly in my scss files, is not the recommended way to do this sass loader marks this as 'deprecated'. |
I'm having the same issue. |
I'm having the same problem. |
I am also having this issue, can anyone provide a way out of this. |
same! anyone knows a temporary fix? |
as suggested above in one of the comments moved the fonts imports to |
Same here. Angular: 7.2.4 |
The issue has been around for a year already :( Is it going to be fixed? :) |
Having the same issue... |
I ran into this problem as well, for us using the bundle rename feature fixed it. Unsure why currenty.
|
I am using Angular v8.1.2 with SCSS as the style format, and found the global syles.scss is not working. In my angular.json, it is:
My solution:
|
I found out that if you extract the font import you need (only one for me) to a dedicated fonts.scss file and you add that one file in the first position of the styles array of the angular.json file then it works (at least for me...) So here is a subset of my angular.json "styles": [
"src/assets/fonts/fonts.scss",
{
"input": "node_modules/@progress/kendo-theme-default/dist/all.css"
},
"src/assets/vendor/some_vendor_things.min.css",
"src/global.scss"
], Previously the fonts.scss was imported from within the global.css. HTH |
This is workaround, worked for me. const file = fs.createWriteStream("src/variables.scss"); Step 2 : update package.json file with below script |
This answer above is the real answer: |
@waterplea If that is the case, then I think there should at least be some kind of warning during the build, that the imports are stripped, because they wouldn't be emitted at the start of the css file. It's taken me quite a while to find this thread. |
I have created a staging environment This works with the font I set on body this don't "configurations": { Please help |
After tried, i found that it will import font only if
A.css content => @import url('https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700'); .body { font-family: Poppins } styles config in angular.json "styles": [ "src/A.css", "other.scss" ], Give a try My env is _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | | /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___| |___/ Angular CLI: 8.3.21 Node: 10.17.0 OS: darwin x64 Angular: 8.2.14 ... animations, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Package Version ----------------------------------------------------------- @angular-devkit/architect 0.803.21 @angular-devkit/build-angular 0.803.21 @angular-devkit/build-optimizer 0.803.21 @angular-devkit/build-webpack 0.803.21 @angular-devkit/core 8.3.21 @angular-devkit/schematics 8.3.21 @angular/cli 8.3.21 @ngtools/webpack 8.3.21 @schematics/angular 8.3.21 @schematics/update 0.803.21 rxjs 6.4.0 typescript 3.5.3 webpack 4.39.2 |
I was able to replicate the issue as well. I have a project which had two .scss in the styles array in the angular.json file, moving the second one and just leaving the src/styles.scss as mentioned above, did the trick. Even though the font is being imported in another .scss in a separate angular project that I'm using in my web app, the issue was caused in the web app instead. The final version of my angular.json's styles array looks like this: This is my env setup:
|
Any updates on this. |
Any idea why this is not being fixed. Is this not considered to be an issue? |
Simply include google fonts into index.html in |
Does this problem have a standard (no workaround) solution yet? |
Pls refer to comment from @kwdiggs & https://stackoverflow.com/questions/9860763/css-import-and-the-order-of-it#answer-9860774 I managed to get this working by having the imports in a different file and placing it first in the angular.json file "styles": [ |
angular 9, added link tag in the index.html and still doesn't work |
Just in case anyone finds this page, like I did... I had what appeared to be a similar issue (font working in development, but not when deployed). The difference for me was that it was working locally in a production build too - so, just a problem after deployment. I am using Angular 9 and deploying to Amazon AWS using serverless. What fixed the issue for me was to ensure the correct font MIME type was listed in the |
facing the same issue for angular 7, Any update on this one. |
Hi all, Embedding the contents of non local external stylesheets in other css files was an undesired side-effect which was removed in version 6. In version 11, we added an optimization to inline Google fonts and icons as part of index.html This will improve improve the First Contentful Paint of the application. See #18926 for more context. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
Repro steps
ng serve --prod
Observed behavior
The https://fonts.googleapis.com/icon?family=Material+Icons file contents are absent in the output bundles.
If we do the same thing on angular v 5.2.0, the file contents ARE in the bundle.
If we do the same thing, but run
ng serve
without--prod
flag, the file contents ARE in the bundleDesired behavior
The https://fonts.googleapis.com/icon?family=Material+Icons file contents should be present in the output bundle, just like it did in 5.2.0.
Mention any other details that might be useful (optional)
This issue appeared only after I updated angular from v5.2.0 to v6.0.1
The text was updated successfully, but these errors were encountered: