New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-optimize-css-modules

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-optimize-css-modules

Mangles the classnames generated by postcss-modules in vite

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-19.63%
Maintainers
0
Weekly downloads
 
Created
Source

Vite Plugin - Optimize CSS Modules

Mangle classnames in production - save up to 20% on css for free!

CI Status Install count Current version Support me

Setup

This plugin requires vite of v3 or greater. It only makes sense to use if you're using css modules.

$ npm install --save-dev vite-plugin-optimize-css-modules

In your vite.config.ts simply add the plugin:

import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
import { defineConfig } from 'vite';

export default defineConfig({
    plugins: [
        optimizeCssModules()
    ]
})

And that's it. When running vite build your generated CSS should be significantly smaller.

How does it work?

By default, when using css modules, you end up with hashes or other long class-names in your bundled css files:

@keyframes _close-card_pzatx_1 {
    /* ...css */
}

._card_pzatx_32 {
    /* ...css */
}

._back_pzatx_49 ._content_pzatx_70 ._close_pzatx_74 {
    /* ...css */
}

By using this module, the smalles possible classname will be used for each "id":

@keyframes a {
    /* ...css */
}

.v {
    /* ...css */
}

.c .s .w {
    /* ...css */
}

Keywords

FAQs

Package last updated on 10 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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