Skip to content
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

Generated css declares fonts multiple times (Roboto, NotoSans) #5931

Closed
jimitndiaye opened this issue Mar 24, 2016 · 5 comments
Closed

Generated css declares fonts multiple times (Roboto, NotoSans) #5931

jimitndiaye opened this issue Mar 24, 2016 · 5 comments
Assignees
Milestone

Comments

@jimitndiaye
Copy link

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/
http://ionicworldwide.herokuapp.com/

Short description of the problem:

Generated app.md.css and app.wp.css (the only ones the reference external fonts, have the font declarations repeated 21 times each inflating the file size, especially if you want to embed some of the smaller font files as data-urls.

What behavior are you expecting?

Each font-face should be declared only once.

Steps to reproduce:

  1. Create a v2 ionic app
  2. Build it
  3. Check out the generated CSS.

I believe the culprit is the use of @at-root in default.wp.scss and default.md.scss. I don't think node-sass (on which gulp-sass depends) understands it.

// Noto Sans Font
@at-root {
  @import "../fonts/noto-sans";
}

I
Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Which Ionic Version? 1.x or 2.x
2.x

Run ionic info from terminal/cmd prompt: (paste output below)

@Ionitron Ionitron added the v2 label Mar 24, 2016
@jgw96 jgw96 added css labels Mar 24, 2016
@jgw96
Copy link
Contributor

jgw96 commented Mar 24, 2016

@jimitndiaye Good Catch! Thanks for pointing this out!

@brandyscarney brandyscarney self-assigned this Mar 24, 2016
@brandyscarney brandyscarney added this to the 2.0.0-beta.5 milestone Mar 24, 2016
brandyscarney added a commit that referenced this issue Apr 11, 2016
globals.mode is already imported in the components.mode file, so it
doesn’t need to be imported per component

fixes #5931
@brandyscarney
Copy link
Member

Thank you for finding this! It was caused by importing the global mode file in each component. I removed these imports from all of the components and confirmed it only includes the fonts once now. This will be fixed in the beta.5 release. Thanks again! 😄

brandyscarney added a commit that referenced this issue Apr 11, 2016
the user will need to include this import themselves if they include
components individually

fixes #5931
@brandyscarney
Copy link
Member

So since we want to be able to individually import components, the globals file needs to be imported in each component. I've reverted the previous commit and instead moved the font import up to the components.<mode>.scss file.

@jimitndiaye
Copy link
Author

jimitndiaye commented Apr 27, 2016

The latest change, while reducing the problem (down to 5 references to Roboto, for instance), did not eliminate it. Still my app.md.css has gone down to 946 KB unminified (down from over 7 MB) so my thanks for that.

@brandyscarney
Copy link
Member

I am only seeing 4, one for each font-weight:

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 300;
  src: local("Roboto Light"), local("Roboto-Light"), url("../fonts/roboto-light.ttf") format("truetype"), url("../fonts/roboto-light.woff") format("woff"); }

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  src: local("Roboto"), local("Roboto-Regular"), url("../fonts/roboto-regular.ttf") format("truetype"), url("../fonts/roboto-regular.woff") format("woff"); }

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  src: local("Roboto Medium"), local("Roboto-Medium"), url("../fonts/roboto-medium.ttf") format("truetype"), url("../fonts/roboto-medium.woff") format("woff"); }

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  src: local("Roboto Bold"), local("Roboto-Bold"), url("../fonts/roboto-bold.ttf") format("truetype"), url("../fonts/roboto-bold.woff") format("woff"); }

Are you seeing something different?

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants