Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vdegenne/rollup-plugin-md-icon-localize
Rollup plugin that localizes md-icon.
https://github.com/vdegenne/rollup-plugin-md-icon-localize
Last synced: about 2 months ago
JSON representation
Rollup plugin that localizes md-icon.
- Host: GitHub
- URL: https://github.com/vdegenne/rollup-plugin-md-icon-localize
- Owner: vdegenne
- License: mit
- Created: 2023-08-14T16:57:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-27T12:56:46.000Z (about 1 year ago)
- Last Synced: 2024-11-08T20:32:04.999Z (about 2 months ago)
- Language: TypeScript
- Size: 167 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Why?
If you use `` element from [Material Web 3](https://github.com/material-components/material-web) you probably noticed that there are two inconvenients:
- You don't have the font file locally.
- The requested font file is rather big and include all Material Symbols (around 3.5MB)This rollup plugin can be used to download the font file that includes only the icons found in your source code.
## Installation
```
npm i -D rollup-plugin-md-icon-localize
```## Usage
Just import the module and add it to the plugins list
```javascript
import {mdIconLocalize} from 'rollup-plugin-md-icon-localize';export default {
plugins: [mdIconLocalize()],
};
```Here are the background steps that the plugin goes through:
- Scans the source code and builds a list of all icons found.
- Downloads minimum size font file for your code. 2 files are created:
- `material-symbols.woff2`: The font file itself.
- `material-symbols.css` : The stylesheet importing the font and defining the icon class.
You need to import this file somewhere in your code to resolve the codepoints.
- Replaces all found icon names in your code with their appropriate codepoint.In the end your code will have codepoints for names and a size shortened local font file.
That's really all about it.## Caveats
When using Vite in dev/watch mode you will have to restart vite server everytime you add a new icon name.
## Contributing
If you find some problems or want to propose an improvement, please open an issue to report and PR's are warmly welcomed.
## License
MIT (c) 2023 Valentin Degenne.