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

377
Visualizações
vite: importing css/sass into component should not also include styles in style.css

I am using something like this to import styles from a sass file into a lit component:

import { html, unsafeCSS, LitElement } from "lit";
import local_css from "/src/static/component_styles.sass";

export class MyApp extends LitElement{
  static styles = unsafeCSS(local_css);
} 

The styles are correctly injected into the js code when building the app but the component_styles.sass is additionally bundled into a styles.css.

And what's worse, the styles from component_styles.sass are loaded as global styles by the development server. So the local component's styles affect the DOM around the component in development. That defeats the purpose of component development.

Is there a way to avoid that? There is a discussion (but so far not a solution) about this here on vite's github

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

0

Thanks to franktopel and tarnishablec in https://github.com/vitejs/vite/issues/3246 I got an answer: adding "?inline" to the import apparently keeps the styles local to the component. Works for both development and production.

import local_css from "/src/static/component_styles.sass?inline";
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