Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into patch-optimize-order
Browse files Browse the repository at this point in the history
  • Loading branch information
KTibow committed Dec 20, 2023
1 parent b50a6e7 commit 9ca4e56
Show file tree
Hide file tree
Showing 128 changed files with 1,843 additions and 1,361 deletions.
30 changes: 30 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"parserOptions": {
"ecmaVersion": 2021
},
"env": {
"node": true,
"es2021": true
},
"extends": ["eslint:recommended"],
"overrides": [
{
"files": ["rollup.config.js", "**/*.mjs"],
"parserOptions": {
"sourceType": "module"
}
},
{
"files": ["**/*.cjs"],
"parserOptions": {
"sourceType": "commonjs"
}
},
{
"files": ["**/*.test.js"],
"env": {
"jest": true
}
}
]
}
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,9 +24,10 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- SVGO Version [e.g. 2.0.3]
- NodeJs Version [e.g 14.0.4]
- OS: [e.g. iOS]


- SVGO Version [e.g. 2.0.3]
- NodeJs Version [e.g 14.0.4]
- OS: [e.g. iOS]

**Additional context**
Add any other context about the problem here.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/plugin_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest a plugin for this project
title: ''
labels: 'New plugin'
assignees: ''

---

**Is your plugin request related to a problem? Please describe.**
Expand All @@ -19,4 +18,5 @@ A clear and concise description of what you want to happen.
Include any links pointing to relevant specs or general knowledge that may validate your plugin idea.

**Implementation**

- [ ] Are you volunteering to work on this plugin?
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: monthly
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE }}
cache: yarn
Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE }}
cache: yarn
Expand All @@ -53,7 +53,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand Down
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
spec: '@yarnpkg/plugin-interactive-tools'

yarnPath: .yarn/releases/yarn-3.2.3.cjs
842 changes: 455 additions & 387 deletions CHANGELOG-old.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ If you've found a bug with SVGO, [create an issue](https://github.com/svg/svgo/i

Your issue should ideally contain:

* A concise description of the bug.
* How you were using SVGO, the version of the tool, and any configuration or command-line options.
* The SVG that was effected, or a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example).
- A concise description of the bug.
- How you were using SVGO, the version of the tool, and any configuration or command-line options.
- The SVG that was effected, or a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example).

If you haven't found a bug, but need help using SVGO in your project, please consider asking on [Stack Overflow](https://stackoverflow.com/questions/tagged/svgo) with the `[svgo]` tag, you may get help faster there. You can still create an issue if the confusion stemmed from a lack of documentation.

Expand All @@ -20,8 +20,8 @@ See: [SECURITY.md](./SECURITY.md)

### Requirements

* [Git](https://git-scm.com/)
* [Node.js 14](https://nodejs.org/) or later
- [Git](https://git-scm.com/)
- [Node.js 14](https://nodejs.org/) or later

### Getting Started

Expand Down
73 changes: 39 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SVG files, especially those exported from vector editors, usually contain a lot

## Installation

You can install SVGO globablly through npm, yarn, or pnpm. Alternatively, drop the global flag (`global`/`-g`) to use it in your Node.js project.
You can install SVGO globally through npm, yarn, or pnpm. Alternatively, drop the global flag (`global`/`-g`) to use it in your Node.js project.

```sh
# npm
Expand All @@ -32,6 +32,7 @@ Process single files:
```sh
svgo one.svg two.svg -o one.min.svg two.min.svg
```

Process a directory of files recursively with `-f`/`--folder`:

```sh
Expand All @@ -51,13 +52,14 @@ SVGO has a plugin architecture. You can read more about all plugins in [Plugins
SVGO reads the configuration from `svgo.config.js` or the `--config path/to/config.js` command-line option. Some other parameters can be configured though command-line options too.

**`svgo.config.js`**

```js
module.exports = {
multipass: false, // boolean
datauri: 'base64', // 'base64'|'enc'|'unenc'
js2svg: {
indent: 4, // number
pretty: false // boolean
pretty: false, // boolean
},
plugins: [
'preset-default', // built-in plugins enabled by default
Expand All @@ -67,17 +69,19 @@ module.exports = {
{
name: 'prefixIds',
params: {
prefix: 'uwu'
}
}
]
prefix: 'uwu',
},
},
],
};
```

### Default preset

Instead of configuring SVGO from scratch, you can tweak the default preset to suit your needs by configuring or disabling the respective plugin.

**`svgo.config.js`**

```js
module.exports = {
plugins: [
Expand All @@ -91,11 +95,11 @@ module.exports = {
// customize the params of a default plugin
inlineStyles: {
onlyMatchedOnce: false,
}
}
}
}
]
},
},
},
},
],
};
```

Expand All @@ -106,6 +110,7 @@ You can find a list of the default plugins in the order they run in [Preset Defa
You can also specify custom plugins:

**`svgo.config.js`**

```js
const importedPlugin = require('./imported-plugin');

Expand All @@ -120,9 +125,9 @@ module.exports = {
params: {
paramName: 'paramValue',
},
fn: (ast, params, info) => {}
}
]
fn: (ast, params, info) => {},
},
],
};
```

Expand All @@ -139,7 +144,7 @@ const { optimize } = require('svgo');

const result = optimize(svgString, {
path: 'path-to.svg', // recommended
multipass: true // all other config fields are available here
multipass: true, // all other config fields are available here
});

const optimizedSvgString = result.data;
Expand All @@ -163,29 +168,29 @@ const config = await loadConfig(configFile, cwd);

## Other ways to use SVGO

| Method | Reference |
| --- | --- |
| Web app | [SVGOMG](https://jakearchibald.github.io/svgomg/) |
| Grunt task | [grunt-svgmin](https://github.com/sindresorhus/grunt-svgmin) |
| Gulp task | [gulp-svgmin](https://github.com/ben-eb/gulp-svgmin) |
| Webpack loader | [image-minimizer-webpack-plugin](https://github.com/webpack-contrib/image-minimizer-webpack-plugin/#optimize-with-svgo) |
| PostCSS plugin | [postcss-svgo](https://github.com/cssnano/cssnano/tree/master/packages/postcss-svgo) |
| Inkscape plugin | [inkscape-svgo](https://github.com/konsumer/inkscape-svgo) |
| Sketch plugin | [svgo-compressor](https://github.com/BohemianCoding/svgo-compressor) |
| Rollup plugin | [rollup-plugin-svgo](https://github.com/porsager/rollup-plugin-svgo) |
| Visual Studio Code plugin | [vscode-svgo](https://github.com/1000ch/vscode-svgo) |
| Atom plugin | [atom-svgo](https://github.com/1000ch/atom-svgo) |
| Sublime plugin | [Sublime-svgo](https://github.com/1000ch/Sublime-svgo) |
| Figma plugin | [Advanced SVG Export](https://www.figma.com/c/plugin/782713260363070260/Advanced-SVG-Export) |
| Linux app | [Oh My SVG](https://github.com/sonnyp/OhMySVG) |
| Browser extension | [SVG Gobbler](https://github.com/rossmoody/svg-gobbler) |
| API | [Vector Express](https://github.com/smidyo/vectorexpress-api#convertor-svgo) |
| Method | Reference |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| Web app | [SVGOMG](https://jakearchibald.github.io/svgomg/) |
| Grunt task | [grunt-svgmin](https://github.com/sindresorhus/grunt-svgmin) |
| Gulp task | [gulp-svgmin](https://github.com/ben-eb/gulp-svgmin) |
| Webpack loader | [image-minimizer-webpack-plugin](https://github.com/webpack-contrib/image-minimizer-webpack-plugin/#optimize-with-svgo) |
| PostCSS plugin | [postcss-svgo](https://github.com/cssnano/cssnano/tree/master/packages/postcss-svgo) |
| Inkscape plugin | [inkscape-svgo](https://github.com/konsumer/inkscape-svgo) |
| Sketch plugin | [svgo-compressor](https://github.com/BohemianCoding/svgo-compressor) |
| Rollup plugin | [rollup-plugin-svgo](https://github.com/porsager/rollup-plugin-svgo) |
| Visual Studio Code plugin | [vscode-svgo](https://github.com/1000ch/vscode-svgo) |
| Atom plugin | [atom-svgo](https://github.com/1000ch/atom-svgo) |
| Sublime plugin | [Sublime-svgo](https://github.com/1000ch/Sublime-svgo) |
| Figma plugin | [Advanced SVG Export](https://www.figma.com/c/plugin/782713260363070260/Advanced-SVG-Export) |
| Linux app | [Oh My SVG](https://github.com/sonnyp/OhMySVG) |
| Browser extension | [SVG Gobbler](https://github.com/rossmoody/svg-gobbler) |
| API | [Vector Express](https://github.com/smidyo/vectorexpress-api#convertor-svgo) |

## Donors

| [<img src="https://sheetjs.com/sketch128.png" width="80">](https://sheetjs.com/) | [<img src="https://raw.githubusercontent.com/fontello/fontello/8.0.0/fontello-image.svg" width="80">](https://fontello.com/) |
| :---: | :---: |
| [SheetJS LLC](https://sheetjs.com/) | [Fontello](https://fontello.com/) |
| :------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: |
| [SheetJS LLC](https://sheetjs.com/) | [Fontello](https://fontello.com/) |

## License and Copyright

Expand Down
2 changes: 1 addition & 1 deletion bin/svgo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const colors = require('picocolors');
const { program } = require('commander');
const makeProgram = require('../lib/svgo/coa');
makeProgram(program);
program.parseAsync(process.argv).catch(error => {
program.parseAsync(process.argv).catch((error) => {
console.error(colors.red(error.stack));
process.exit(1);
});
4 changes: 2 additions & 2 deletions docs/01-index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Introduction
slug: "introduction"
slug: 'introduction'
---

SVGO (short for SVG Optimizer) is a Node.js library and command-line application for optimizing SVG files.
Expand All @@ -11,7 +11,7 @@ SVG files, especially those exported from vector editors, usually contain a lot

### System Requirements

* [Node.js 14](https://nodejs.org/) or later
- [Node.js 14](https://nodejs.org/) or later

<Tabs>
<TabItem value="npm" label="npm" default>
Expand Down
Loading

0 comments on commit 9ca4e56

Please sign in to comment.