P
P
postya2020-11-17 15:53:00
Fonts
postya, 2020-11-17 15:53:00

Why is custom font not being applied in Vue with Sass?

I have a Vue JS application I use the
sass preprocessor
I want to use a custom font through font-face. There are no errors anywhere, but the font is not applied

. What could be the problem? maybe I somehow connected the font wrong?

vue.config.js:

module.exports = {
  devServer: {
    port: 11000,
  },
  css: {
    loaderOptions: {
      sass: {
        prependData: `
        @import "@/assets/scss/styles.scss";
        @import "[email protected]/assets/scss/fonts.scss";
        `,
      },
    },
  },
};


project structure:
5fb3c6c32cd69829087821.jpeg

fonts.scss:
@font-face {
  font-family: "Modak";
  src: local("Modak");
  src: url("[email protected]/assets/fonts/Modak/Modak-Regular.ttf") format("ttf");
  font-weight: 400;
}


HTML:
h2 {
    font-size: $font-size * 2;
    font-family: "Modak", sans-serif;
    text-transform: uppercase;
    font-weight: normal;
  }


5fb3c732ea65d105684535.jpeg

5fb3c739eec81764454468.jpeg

the font itself should look like this:
5fb3c777c7f75540666777.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
postya, 2020-11-17
@postya

In the fonts.scss file, format was incorrectly specified in the src line, you need to do it like this:
src: url("[email protected]/assets/fonts/Modak/Modak-Regular.ttf") format("truetype");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question