Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

369
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!