Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

373
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda