![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
If you're using external SVG sprites for your icon system there is a good chance you have a lot of unused icons at the end.
PurgeSvg will analyze your content and remove all unused icons. This will make your SVG file a lot smaller.
It also enables you to merge more SVG files into one and thereby reducing network requests.
:bangbang: Warning :bangbang:️
Be aware that external SVG sprites are not supported in any version of IE. If you need support for IE check out svg4everybody.
:heart: Gratitude :heart:
This package was inspired (and some code copied) from Purgecss
Start by installing the package globally
npm i -g purgesvg
PurgeSvg is available via a CLI. You can use the CLI by itself or with a configuration file.
To see the available options for the CLI: purgesvg --help
purgesvg --content <content> --svgs <svgs> [option]
Options:
-c, --config configuration file [string]
-o, --out Filepath directory to write purified svg files to [string]
-w, --whitelist List of id's that should not be removed [array] [default: []]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
purgesvg --config /path/to/config.js
:heavy_check_mark: When not using a configuration file the --content
and --svgs
options are required.
Content that should be analyzed. An array of filenames or glob.
purgesvg --content index.html /resource/assets/**/*.vue --svgs ...
SVG files to purge. An array of filenames or glob.
purgesvg --content index.html --svgs /images/icons.svg /icons/solid.svg
Output path for purged SVGs.
The output path can be:
filename.purged.svg
purgesvg --content index.html --svgs /icons/*.svg --out /build/purged/icons.svg
List of whitelist ids. Id's will be whitelisted for all SVG files.
purgesvg --content index.html --svgs /icons/*.svg --whitelist rocket heart times
Start by installing the package as a development dependency
npm i --save-dev purgesvg
You can use PurgeSvg in your javascript file. Just require the package, create the new PurgeSvg class, add configuration options and call the purge method.
The constructor accepts a configuration object or a path to the configuration file.
const PurgeSvg = require('purgesvg')
new PurgeSvg({
content: './__tests__/test_examples/clean_svgs/index.html',
svgs: [{
in: './__tests__/test_examples/clean_svgs/icons.svg',
out: tempFolder
}],
whitelist: {'*': ['building']}
}).purge()
:wrench: TODO :hammer:
Content that should be analyzed. The content option is an array of files or globs.
new PurgeSvg({
content: ['index.html', `**/*.js`, '**/*.html', '**/*.vue'],
...
}
A list of SVG files that should be purged and their output configuration. The list could be an array of files/globs or an array of objects.
When provided as an array of strings (files/globs) the purged file will be saved in the same folder as the original as filename.purged.svg
.
new PurgeSvg({
svgs: ['images/icons.svg'], // purged file will be saved in 'images/icons.purged.svg'
...
}
Providing an array of objects enables more versatility. Some examples of different options:
new PurgeSvg({
svgs: [
// purged file will be saved in 'build/images/icons.svg'
{
in: 'images/icons.svg', // full path
out: 'build/images' // only folder
},
// purged AND MERGED files will be saved in 'build/images/merged.svg'
{
in: 'icons/*.svg', // glob
out: 'build/images/merged.svg' // full path
}
],
...
}
Provides the option to whitelist ids of SVG sprites. The option can be used to whitelist ids for all files or only for specific SVG files.
new PurgeSvg({
whitelist: {
'*': new Set(['rocket', 'heart', ...]), // whitelist id's for all files
'solid.svg': new Set(['building', 'times', ...]) // whitelist id's only for a specific file
},
...
}
The configuration file is a simple JavaScript file containing options:
module.exports = {
content: ['index.html'],
svgs: [{
in: 'images/*.svg'
}],
whitelist: {
'*': new Set(['rocket', 'building'])
}
}
FAQs
Remove unused svg symbols and optionaly merge svg files
We found that purgesvg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.