Gathering detailed insights and metrics for lit-scss-loader
Gathering detailed insights and metrics for lit-scss-loader
Gathering detailed insights and metrics for lit-scss-loader
Gathering detailed insights and metrics for lit-scss-loader
A webpack loader that automatically generates the JavaScript style that is required for LitElement, simply by importing the CSS/SCSS file.
npm install lit-scss-loader
Typescript
Module System
Node Version
NPM Version
JavaScript (41.96%)
TypeScript (28.47%)
CSS (25.25%)
HTML (2.18%)
SCSS (2.14%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
64 Stars
93 Commits
13 Forks
3 Watchers
13 Branches
5 Contributors
Updated on Mar 09, 2025
Latest Version
2.0.1
Package Id
lit-scss-loader@2.0.1
Unpacked Size
201.89 kB
Size
60.37 kB
File Count
22
NPM Version
8.1.2
Node Version
16.17.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
It is a fork of polymer-css-loader! But since the loader was only developed for polymer, I adopted it for lit-element, now lit.
A loader for webpack that lets you import the CSS/SCSS into your lit-element and automatically creates the styling JavaScript for you.
While this loader has worked well on my Windows machine, there may still be unforeseen bugs. Even though I put the package to v1.0 be cautious when using it in production.
npm i -D lit-scss-loader extract-loader
1module.exports = { 2 entry: './src/index.js', 3 module: { 4 rules: [ 5 { 6 test: /\.css|\.s(c|a)ss$/, 7 use: [{ 8 loader: 'lit-scss-loader', 9 options: { 10 minify: true, // defaults to false 11 }, 12 }, 'extract-loader', 'css-loader', 'sass-loader'], 13 }, 14 ], 15 }, 16};
1import {html, LitElement} from 'lit'; 2 3import Style1 from './style-1.scss'; 4import Style2 from './style-2.css'; 5 6class LitTestComponent extends LitElement { 7 8 constructor() { 9 super(); 10 this.prop1 = '🔥-app'; 11 } 12 13 static get properties() { 14 return { 15 prop1: { 16 type: String 17 } 18 }; 19 } 20 21 static get styles() { 22 return [Style1, Style2]; 23 } 24 25 render() { 26 return html` 27 <p>This is the test component</p> 28 <p>This is the propertie's value: ${this.prop1} </p> 29 <div id="test">This font size should be bigger</div> 30 `; 31 } 32} 33 34customElements.define('lit-test-component', LitTestComponent);
If you're using this loader in a Typescript project, you will also need to inform the compiler that it has the ability
to load CSS/SCSS files. This project already provides the module declarations, so all you need to do is include the type
declaration file in your tsconfig.json
file.
1{ 2 "compilerOptions": { 3 "...": "..." 4 }, 5 "include": [ 6 "node_modules/lit-scss-loader/types.d.ts" 7 ] 8}
Name | Type | Default | Description |
---|---|---|---|
minify | {Boolean} | false | When true, it will minify both the CSS and JavaScript output. |
defaultSkip | {Boolean} | false | (dep.) When true, will skip all imports except those explicilty marked. |
These were applicable when using Polymer 3. With lit, everything is better.
They are appended at the end of the CSS imports in your JavaScript file (Where the component is declared); E.g:
1import './style-2.css?include'; 2import './style-1.css?skip';
Name | Type | Default | Description |
---|---|---|---|
skip | {boolean} | N/A | Setting this parameter will skip the import altogether. This may be useful if you're using React and Lit or you'd like to include the CSS without. E.g: import './style-2.css?skip' |
include | {boolean} | N/A | Just setting this parameter will include the css even when defaultSkip is on. This may be useful if you just want to "litify" or "web-componentize" a .css/.scss/.less file. E.g: import './style-2.css?include' . Note: include will take preference over skip . |
First build lit-scss-loader with npm run build
inside the root, then navigate to test-app and execute: npm start
. It will
launch an express server @ localhost:3000.
The loader automatically injects code (e.g. import {css} from 'lit';
) into your files, therefore, pay attention if you
need es5 / legacy browsers support. As LambyPants mentioned, you
might have to adopt your loaders configuration to also test for /\.js$|\.ts$|\.s(c|a)ss$/
and transform it to your
needed language support.
When using css for components inline or inside a javascript file we will lose auto-completion or any analysis tools that are already out there for plain CSS/SCSS files. Also, designer may don't want to work inside .js files. Let them work with what they are used to.
With this, you just import your .css in your lit-component, add the style-variable to the static get styles() and you're set! The loader takes care for creating the content of that variable!
Open a GitHub issue now! 😊
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/12 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
38 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More