Skip to content
/ libsvgo Public
forked from svg/svgo

[Use svgo@2 dist browser bundle] The core code of SVGO, optimized to be portable

License

Notifications You must be signed in to change notification settings

dr-js/libsvgo

 
 

Repository files navigation

libsvgo

i:npm i:ci i:size i:npm-dev

The core code of SVGO, optimized to be portable


  • 📁 lib/ & plugins/
    • main source code, in output package will be:
      • libsvgo/lib/ & libsvgo/plugins/: for direct use, use require() / exports.*=
      • libsvgo/module/lib/ & libsvgo/module/plugins/: for use with node + @babel/register, keep import / export and readability
      • libsvgo/webpack/SVGO.js: all-in-one packaged version, can be used in browser like <script src="https://unpkg.com/libsvgo/webpack/SVGO.js"></script>, and provide window.SVGO (experimental)
  • 📁 test/
    • test code & resource file
  • 📁 examples/
    • code example

This repo is a heavily changed fork of SVGO, mainly:

  • ES6+ code update & re-format
  • drop cli and option parsing code to reduce size
  • drop node-specific module to allow both Browser and Node use

And is expected to be used by nodejs@>=12 or recent-enough Browser


sample usage: (ES6 module)

// get most used from main entry
import { SVGO, SVGO_LITE, CONFIG_LITE, PLUGINS_DEFAULT_LIST } from 'libsvgo/module/lib/svgo'

// or get each separately
import { SVGO_LITE } from 'libsvgo/module/lib/svgo-lite'
import { SVGO_LITECONFIG_LITE } from 'libsvgo/module/lib/svgo/config-lite'

// get each plugin separately
import * as addAttributesToSVGElement from 'libsvgo/module/plugins/addAttributesToSVGElement'

sample usage: (Node.js module through Babel)

// get most used from main entry
const { SVGO, SVGO_LITE, CONFIG_LITE, PLUGINS_DEFAULT_LIST } = require('libsvgo/lib/svgo')

// or get each separately
const { SVGO_LITE } = require('libsvgo/lib/svgo-lite')
const { SVGO_LITECONFIG_LITE } = require('libsvgo/lib/svgo/config-lite')

// get each plugin separately
const addAttributesToSVGElement = require('libsvgo/plugins/addAttributesToSVGElement')

sample usage: (ES6 Webpack bundle)

// `require()` in nodejs
const SVGO = require('libsvgo/webpack/SVGO')
// or load from `<script src="https://unpkg.com/libsvgo/webpack/SVGO.js"></script>` in browser

// get common lib (not all is exposed)
const { SVGO_LITE, CONFIG_LITE, PLUGINS_DEFAULT_LIST, PLUGINS_MAP } = SVGO

// get plugin
const { addAttributesToSVGElement } = PLUGINS_MAP

also check examples/ for basic usage

About

[Use svgo@2 dist browser bundle] The core code of SVGO, optimized to be portable

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%