Gathering detailed insights and metrics for posthtml-css-modules
Gathering detailed insights and metrics for posthtml-css-modules
Gathering detailed insights and metrics for posthtml-css-modules
Gathering detailed insights and metrics for posthtml-css-modules
npm install posthtml-css-modules
Typescript
Module System
Node Version
NPM Version
67.5
Supply Chain
98.1
Quality
77.2
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
55 Stars
29 Commits
5 Forks
3 Watchers
1 Branches
11 Contributors
Updated on Dec 10, 2024
Latest Version
0.1.3
Package Id
posthtml-css-modules@0.1.3
Size
3.47 kB
NPM Version
5.4.0
Node Version
6.9.5
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
2
PostHTML plugin that inlines CSS modules in HTML.
I suggest using postcss-modules to generate CSS modules. Check the PostHTML documentation for integration examples with grunt, gulp, and other build systems.
If you're more into webpack then you don't need all these modules at all.
With css
, style
, and html
loaders you can achieve the same result:
css-modules-webpack-example
Let's say we have cssClasses.json
with all CSS modules inside:
1{ 2 "title": "_title_116zl_1 _heading_9dkf", 3 "profile": { 4 "user": "_profile_user_f93j" 5 } 6}
Now we can inline these CSS modules in our HTML:
1var posthtml = require('posthtml'); 2 3posthtml([require('posthtml-css-modules')('./cssClasses.json')]) 4 .process( 5 '<h1 css-module="title">My profile</h1>' + 6 // You can also use nested modules 7 '<div css-module="profile.user">John</div>' 8 ) 9 .then(function (result) { 10 console.log(result.html); 11 }); 12 13// <h1 class="_title_116zl_1 _heading_9dkf">My profile</h1> 14// <div class="_profile_user_f93j">John</div>
CSS modules could be also separated into several files.
For example, profile.js
and article.js
inside directory cssModules/
:
1// profile.js 2module.exports = { 3 user: '_profile_user_f93j' 4}
1// article.js 2module.exports = { 3 title: '_article__tile _heading' 4}
You can use both JS and JSON for a declaration, as long as the file could be required via require()
.
1var posthtml = require('posthtml'); 2 3posthtml([require('posthtml-css-modules')('./cssModules/')]) 4 .process( 5 '<div class="baseWrapper" css-module="profile.user">John</div>' + 6 '<h2 css-module="article.title"></h2>' 7 ) 8 .then(function (result) { 9 console.log(result.html); 10 }); 11 12// <div class="baseWrapper _profile_user_f93j">John</div> 13// <h2 class="_article__tile _heading"></h2>
You can also pass CSS modules as an object to the plugin:
var posthtml = require('posthtml'),
cssModules = {
title: "_title_116zl_1 _heading_9dkf",
profile: {
user: "_profile_user_f93j"
}
};
posthtml([require('posthtml-css-modules')(cssModules)])
.process(
'<h1 css-module="title">My profile</h1>' +
// You can also use nested modules
'<div css-module="profile.user">John</div>'
)
.then(function (result) {
console.log(result.html);
});
// <h1 class="_title_116zl_1 _heading_9dkf">My profile</h1>
// <div class="_profile_user_f93j">John</div>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 3/26 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
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