question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

url() params break when wrapping in strings.

See original GitHub issue

Environment

"linaria": "^1.3.1", "webpack": "^4.29.6",

Description

Using src: url('../../../assets/Roboto-Medium.ttf'); causes the following error:

ERROR in ./.linaria-cache/src/ui/styles/fonts.linaria.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleNotFoundError: Module not found: Error: Can't resolve '../../../assets/Roboto-Medium.ttf' in 'C:\Users\ivan\Desktop\myProject\.linaria-cache\src\ui\styles'

Removing the quotes, eg using src: url(../../../assets/Roboto-Medium.ttf); fixes the issue.

Reproducible Demo

The whole snippet:

import { css } from 'linaria';

export const fonts = css`
  :global() {
    @font-face {
      font-family: 'Roboto';
      font-display: block;
      src: url(../../../assets/Roboto-Medium.ttf);
      font-weight: 700;
    }

    @font-face {
      font-family: 'Roboto';
      font-display: block;
      src: url(../../../assets/Roboto-Medium.ttf);
      font-weight: 500;
    }

    @font-face {
      font-family: 'Roboto';
      font-display: block;
      src: url(../../../assets/Roboto-Regular.ttf);
      font-weight: 400;
    }

    @font-face {
      font-family: 'RobotoMono';
      font-display: block;
      src: url(../../../assets/RobotoMono-Regular.ttf);
      font-weight: 400;
    }
  }
`;

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Anbercommented, Mar 28, 2020

Fixed. Will be released in the next 1.4 beta.

1reaction
satya164commented, Mar 29, 2019

Thanks! The second one was supposed to work, but seems it’s broken. Will fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I break a string in YAML over multiple lines?
Use > most of the time: interior line breaks are stripped out, although you get one at the end: key: > Your long...
Read more >
overflow-wrap - CSS: Cascading Style Sheets - MDN Web Docs
Lines may only break at normal word break points (such as a space between two words). anywhere. To prevent overflow, an otherwise unbreakable ......
Read more >
wordwrap - Manual - PHP
Wraps a string to a given number of characters using a string break character. ... @param float $width - Width, in pixels, of...
Read more >
URL objects - The Modern JavaScript Tutorial
href is the full url, same as url.toString(); protocol ends with the colon character : search – a string of parameters, starts with...
Read more >
Render a String with Non-breaking Spaces in React | Pluralsight
Inside formatString() , set isDisplay to true and copy the string in a temporary variable. Search for any empty spaces using the given...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found