Gathering detailed insights and metrics for purgecss-laminar-webpack-plugin
Gathering detailed insights and metrics for purgecss-laminar-webpack-plugin
Gathering detailed insights and metrics for purgecss-laminar-webpack-plugin
Gathering detailed insights and metrics for purgecss-laminar-webpack-plugin
npm install purgecss-laminar-webpack-plugin
Typescript
Module System
Min. Node Version
TypeScript (97.74%)
JavaScript (2.26%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
15 Commits
2 Watchers
1 Branches
1 Contributors
Updated on Jan 28, 2023
Latest Version
0.1.4
Package Id
purgecss-laminar-webpack-plugin@0.1.4
Unpacked Size
33.01 kB
Size
9.05 kB
File Count
20
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
5
1
Webpack plugin to remove unused css for scala.js + laminar projects.
Derived from the purgecss-webpack-plugin.
The way PurgeCSS works is simple - you give it a list of classes that are actually used (well, normally it extracts this list itself, from a static html, or by extracting "words" from any text file, like a .js
file), and then it uses that list to clean up the CSS, removing everything it believes is unused.
Thus, in order this plugin not to break your app in production - you need to avoid building CSS class names with string interpolation or any other string manipulation functions. Every CSS class must be literally present in your code as a whole string (or a substing separated with whitespace, for example this is perfectly fine: div(cls := "class-1 class-2 class-3")
).
So, this will get broken:
1def component(color: String) = div(cls := s"my-component-$color")
As a workaround one might use the whitelisting (which is a built-in feature of PurgeCSS). See PurgeCSS docs for details on that.
1yarn add purgecss-laminar-webpack-plugin --dev
So far this plugin was tested to work with the extract-css-chunks-webpack-plugin plugin.
1const ExtractCssChunks = require('extract-css-chunks-webpack-plugin'); 2const PurgeCSSLaminarPlugin = require('purgecss-laminar-webpack-plugin').default; 3 4module.exports = { 5 // ... 6 plugins: [ 7 new ExtractCssChunks({ 8 // ... 9 }), 10 new PurgeCSSLaminarPlugin(), 11 ] 12 // ... 13}
See scala-js-laminar-starter.g8 for a full configuration example.
The options available in purgecss Configuration are also available in the webpack plugin with the exception of css
, content
, extractors
and defaultExtractor
.
These options from purgecss-webpack-plugin
are not implemented:
paths
only
Othewise you can check out the purgecss-webpack-plugin documentation for more details about configuration.
You can reduce the number of strings that are considered to be potential CSS class names using the filters (these are applied AFTER the strings have been selected and broken down into CSS-class-name-like tokens):
1export interface StringFilters { 2 exclude?: (RegExp | StringMatcher)[]; 3 include?: (RegExp | StringMatcher)[]; 4 onlyAllLowerCase?: boolean; 5 skipAllUpperCase?: boolean; 6 minLength?: number; 7 maxLength?: number; 8}
1module.exports = { 2 // ... 3 plugins: [ 4 new PurgeCSSLaminarPlugin({ 5 stringFilters: { 6 minLength: 2, 7 maxLength: 30, 8 skipAllUpperCase: true, // filters out strings like 'NOT-A-CLASSNAME', 9 onlyAllLowerCase: true, // filters out strings like 'Not-a-ClassName', 10 exclude: [ 11 // a string will be excluded if ANY of these matches 12 13 /_/ // filters out strings that contain `_`, 14 15 (s) => s.startsWith('a') && s.endsWith('e') // filters out strings that start with an `a` and end with an `e` 16 ], 17 include: [ 18 // same as exclude, but a string will be excluded if NONE of these match 19 ] 20 }, 21 }), 22 ] 23 // ... 24}
Setting { debug: true }
in the plugin options will make it generate a number of files in the .purgecss-laminar-debug/
directory when parsing the .js
files, in case you need to debug something:
1module.exports = { 2 // ... 3 plugins: [ 4 new PurgeCSSLaminarPlugin({ 5 debug: true 6 }), 7 ] 8 // ... 9}
This project is licensed under the MIT License - see the LICENSE file for details.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/15 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no SAST tool detected
Details
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
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