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

How to add fonts #318

Open
jeusdi opened this issue Jan 25, 2018 · 3 comments
Open

How to add fonts #318

jeusdi opened this issue Jan 25, 2018 · 3 comments

Comments

@jeusdi
Copy link

jeusdi commented Jan 25, 2018

I've installed font-awesome:

npm install font-awesome

I've added these rules on constants.js:

exports.MY_CLIENT_RULES = [
  // use this to import your own rules for Client webpack config.
  { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&mimetype=application/font-woff" },
  { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
]

Into my styles.scss I've added this import:

@import "font-awesome/scss/font-awesome.scss";

font-awesome css rules are loaded but, fonts are not loaded.

It seems fonts are requested by browser:

enter image description here

However, the response is the main html page:

enter image description here

Any ideas?

@jeusdi
Copy link
Author

jeusdi commented Jan 30, 2018

Any ideas?

@Zwimber
Copy link

Zwimber commented Mar 9, 2018

The most likely reason is that the path is not entirely correct but I would need more information to exactly pinpoint the problem. I would recommend just using a CDN for now.

Good luck!

@leqwasd
Copy link

leqwasd commented Mar 24, 2018

I think I got it working.
In webpack.config.ts

  {
    test: /\.scss$/,
    loaders: ['to-string-loader', 'css-loader', 'resolve-url-loader', 'sass-loader?sourceMap']
  },
  { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff"},
  { test: /\.(png|jpg|jpeg|gif|svg)$/, loader: "url-loader?limit=10000" },
  { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" },

And in my .scss file I just

@import '~font-awesome/scss/font-awesome.scss'

I am super new to this specific Angular file handling proccess. This was cobbled together from examples all around the web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants