css-loader icon indicating copy to clipboard operation
css-loader copied to clipboard

@font-face wrong syntax

Open renanvalentin opened this issue 10 years ago • 7 comments

Hey guys,

I'm stuck on this problem all day long and I can't find a way to solve this, could you help me please? If minimized is enabled, than the @font-face is stripped out, but if I disable it, the final file comes with a wrong syntax, like this:

@font-face {
{
  font-family: 'whatsgood-fonticon'
;
  src: url(../fonts/whatsgood-fonticon.eot)
;
  src: url(../fonts/whatsgood-fonticon.eot#iefix) format("embedded-opentype"), url(../fonts/whatsgood-fonticon.ttf) format("truetype"), url(../fonts/whatsgood-fonticon.woff) format("woff"), url(../fonts/whatsgood-fonticon.svg#whatsgood-fonticon) format("svg")
;
  font-weight: normal
;
  font-style: normal
}
}

renanvalentin avatar Feb 12 '16 21:02 renanvalentin

Pretty strange, I will take a look later, but this approach works!

@font-face {
  font-family: 'whatsgood-fonticon';
  src: url('./whatsgood-fonticon.eot?pqypst');
  src: url('./whatsgood-fonticon.eot?pqypst#iefix') format('embedded-opentype'),
  url('./whatsgood-fonticon.ttf?pqypst') format('truetype'),
  url('./whatsgood-fonticon.woff?pqypst') format('woff'),
  url('./whatsgood-fonticon.svg?pqypst#whatsgood-fonticon') format('svg');
  font-weight: normal;
  font-style: normal;
}

:global {
  [class^="wg-"], [class*=" wg-"] {
    font-family: 'whatsgood-fonticon' !important;
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .wg-add:before {
    content: "\e900";
  }
  .wg-arrow-down:before {
    content: "\e901";
  }
}

renanvalentin avatar Feb 12 '16 22:02 renanvalentin

Struggling with a similar issue, any quick workaround guys?. I disabled minimizing, but it still adds an extra bracket which browser is not able to parse.

@font-face { { font-family: 'TypoGraphica'; font-style: normal; font-weight: normal; src: url(http://localhost:3001/src/styles/fonts/TypoGraphica.otf) format("opentype"); } }

rahilvirani avatar May 18 '16 03:05 rahilvirani

rahilvirani did you tried my solution above? It worked for me.

renanvalentin avatar May 18 '16 03:05 renanvalentin

I've got same problem. After few mins of research, i found that it adds one more bracket if you put your font-face into :global scope. :global { @font-face { ... } } Put them out and you will be fine.

nindavidw avatar Sep 14 '16 15:09 nindavidw

/cc @renanvalentin @rahilvirani @nindavidw can your create minimal reproduced test repo if error is present or we can close this issue?

alexander-akait avatar Apr 20 '17 14:04 alexander-akait

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!

alexander-akait avatar May 26 '17 16:05 alexander-akait

Hi @evilebottnawi ! I still have this issue as of today, it seems other people do too here : https://github.com/css-modules/css-modules/issues/95 @jmar777 describes the issue pretty well here : https://github.com/css-modules/css-modules/issues/95#issuecomment-369822016 So yeah, pretty annoying for anyone who tries to import an icon font for example.

Thanks a bunch for your work on this 👍 😄 !

mininao avatar Jun 07 '18 09:06 mininao