Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-css-modules-plugin

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-css-modules-plugin - npm Package Compare versions

Comparing version 2.1.3 to 2.1.4

4

changelog.md

@@ -0,1 +1,5 @@

## V2.1.4:
- [v2] add filename as class prefix, e.g.: `.some-class` in `some.module.css` will be transformed to `.some-module__some-class-[hash]`
## V2.1.3:

@@ -2,0 +6,0 @@

12

index.js

@@ -27,2 +27,3 @@ const path = require('path');

const resolveDir = path.dirname(cssFullPath);
const classPrefix = path.basename(cssFullPath, path.extname(cssFullPath)).replace(/\./g, '-') + '__';

@@ -40,6 +41,13 @@ /**

const { code, exports = {}, map, dependencies = [] } = cssHandler.bundle(bundleConfig);
let finalCssContent = code.toString('utf-8');
const cssModulesJSON = {};
Object.keys(exports).forEach((originClass) => {
cssModulesJSON[camelCase(originClass)] = exports[originClass].name;
const patchedClass = exports[originClass].name;
cssModulesJSON[camelCase(originClass)] = classPrefix + patchedClass;
finalCssContent = finalCssContent.replace(
new RegExp(patchedClass, 'g'),
classPrefix + patchedClass
)
});

@@ -49,4 +57,2 @@ const classNames = JSON.stringify(cssModulesJSON, null, 2);

const urls = dependencies.filter((d) => d.type === 'url');
let finalCssContent = code.toString('utf-8');
urls.forEach(({ url, placeholder }) => {

@@ -53,0 +59,0 @@ finalCssContent = finalCssContent.replace(

{
"name": "esbuild-css-modules-plugin",
"version": "2.1.3",
"version": "2.1.4",
"description": "A esbuild plugin to bundle css modules into js(x)/ts(x).",

@@ -21,2 +21,5 @@ "main": "index.js",

},
"devDependencies": {
"esbuild": "^0.14.21"
},
"peerDependencies": {

@@ -32,3 +35,6 @@ "esbuild": "^0.14.21"

"tmp": "^0.2.1"
},
"publishConfig": {
"access": "public"
}
}
# esbuild-css-modules-plugin
[![npm version](https://img.shields.io/npm/v/esbuild-css-modules-plugin.svg?style=flat)](https://www.npmjs.com/package/esbuild-css-modules-plugin)
[![Test](https://github.com/indooorsman/esbuild-css-modules-plugin/actions/workflows/test.yml/badge.svg)](https://github.com/indooorsman/esbuild-css-modules-plugin/actions/workflows/test.yml)

@@ -5,0 +6,0 @@ A esbuild plugin to bundle css modules into js(x)/ts(x).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc