Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

262
Visualizações
Using a # (Hashtag) in a image name in scss/css

Okay let's say i have an image named test#1234.png, while trying to import it as a:

background: url('./assets/test#1234.png')

I would get this error:

Module not found: Error: Can't resolve './assets/test'

So it wouldn't even read out the whole name in the error, I've tried escaping the hashtag like test/#1234 and also percent encoding it like test%231234 but still no luck, anyone got an idea of what could fix this problem?

NOTE: any other file name that doesn't contain a hashtag works.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

It doesn't seem like this error is originating with SASS. Runing the sass command-line tool to compile a single SCSS file with a hashtag will work fine. In general, SASS does no checking of the filesystem to try and resolve paths, it only processes the syntax. The "module not found" error is being triggered by your build process, probably React.

about 4 years ago · Juan Pablo Isaza Relatório

0

The hashtag is a reserved character for URIs (which denotes the fragment).

According to RFC 3986 section 2.2, the reserved characters are:

reserved    = gen-delims / sub-delims

gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"

sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
            / "*" / "+" / "," / ";" / "="

And, importantly:

If data for a URI component would conflict with a reserved character's purpose as a delimiter, then the conflicting data must be percent-encoded before the URI is formed.

The percentage-encoding of the hastag comes out to %23, so instead of
background: url('./assets/test#1234.png')

You would be looking to target:
background: url('./assets/test%231234.png')

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda