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

163
Visualizações
how to add global scss styles to preact app

I created preact template from default preact-cli template

added:

"sass": "^1.45.1",
"sass-loader": "^10.2.0",

import global scss file into index.js and global styles work fine

import "./style/global.scss";
import App from "./components/app";
export default App;

added into global.scss file mixin and scss vars:

@mixin br {
  border-radius: 12px;
}

and when i try to use it in some component like:

 .merchant {
    margin-bottom: 4px;
    @include br;
  }

I get error:

Module build failed (from ../node_modules/preact-cli/lib/lib/webpack/proxy-loader.js):

    @include br;
   ^
      Undefined mixin.
  ╷
6 │     @include br;
  │     ^^^^^^^^^^^
  ╵
  stdin 6:5  root stylesheet
      in ./src/components/header/style.scss (line 6, column 5)
 @ ./components/header/style.scss 2:12-238 9:17-24 13:7-14 45:20-27 47:4-60:5 49:6-59:7 50:38-45 56:26-33 58:21-28 68:15-22
 @ ./components/header/index.js
 @ ./components/app.js
 @ ./index.js
 @ ../node_modules/preact-cli/lib/lib/entry.js

looks like i need to something like loader for this and where I need to add it?

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

0

You'll need to import the SCSS file if you want to use anything from it.

@import 'path/to/global.scss';

.merchant {
    margin-bottom: 4px;
    @include br;
}

To clarify, this is normal practice when working with SCSS; variables and mixins are not added as globals to your loader (and I've never seen a setup where they were, so I'm curious if you've ran into a system like this). The SCSS processor will compile each file individually, so without an import, it won't be able to resolve your mixin.

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