A Vite plugin to shrink and obfuscate CSS classes & IDs in Vue components
A Vite plugin for minifying and obfuscating CSS class and ID names in Vue components, reducing bundle size and making reverse-engineering harder. Ideal for projects with lengthy or numerous class and ID names, it shortens them and masks the originals to optimize component size and protect code privacy.
npm install vite-plugin-uglifier --save-devThe plugin can be used in the vite.config.js file as follows:
plugins: [
vitePluginUglifier({
enableLogging: true,
renameId: true,
include: ['*'],
exclude: []
});
]enableLogging: (boolean) Set totrueto enable console logging. Default isfalse.renameId: (boolean) Set totrueto enable renaming of IDs. Default isfalse.include: (array) Specify the files to include for renaming. Default is['*'](all files).exclude: (array) Specify the files to exclude from renaming. Default is[](none).
The plugin covers the following classes and IDs in Vue components:
classattributes in HTML elementsclassattributes in Vue componentsidattributes in HTML elementsidattributes in Vue componentsclassandidattributes in<style>blocksclassandidattributes in<style scoped>blocksclassandidattributes in<style module>blocksclassandidattributes in<style lang="scss">blocksclassandidattributes in<style lang="sass">blocksclassandidattributes in<style lang="less">blocksclassandidattributes in<style lang="stylus">blocksclassandidattributes in<style lang="postcss">blocksclassandidattributes in<style lang="css">blocks- Note: The plugin does not cover
classandidattributes in<style>blocks that are not scoped or module-based.
- Note: The plugin does not cover
This project is licensed under the 0BSD License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.