Closed rabbanirizwan closed 1 year ago
scss files are not importable by default in a JavaScript/TypeScript project. Build tools like webpack and vite will use loaders/plugins that pre-processes the source code and replaces those imports, so you would need the same for Web Dev Server. I don't see a WDS plugin for importing scss but there exist some for importing css. Here's some guidance on importing css https://modern-web.dev/docs/dev-server/writing-plugins/examples/#importing-css. You could compile scss to css before using those plugins or write a new plugin.
/**
SPDX-License-Identifier: BSD-3-Clause */
import {LitElement, html, css} from 'lit'; import style from './style.scss'; /**
@csspart button - The button */ export class MyElement extends LitElement { static get styles() { return [style] }
static get properties() { return { /**
@type {string} */ name: {type: String},
/**
@type {number} */ count: {type: Number}, }; }
constructor() { super(); this.name = 'World'; this.count = 0; }
render() { return html`
${this.sayHello(this.name)}!
<button @click=${this._onClick} part="button"> Click Count: ${this.count}
`; }
_onClick() { this.count++; this.dispatchEvent(new CustomEvent('count-changed')); }
/**
name
*/ sayHello(name) { returnHello, ${name}
; } }window.customElements.define('my-element', MyElement);