Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: optimize svgos for inline html usage #11

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const { themes } = require('prism-react-renderer');
/**
* Config for Docusaurus.
*
* $.tagline is undefined, as our copy is specified in the code instead.
* $.themeConfig.navbar.logo is undefined as this is configured with a custom component.
* $.themeConfig.footer.style is ignored as this is overriden with custom CSS.
* $.themeConfig.footer.style is ignored as this is overridden with custom CSS.
*
* @type {Config}
*/
const config = {
title: "SVGO",
tagline: "A Node.js library and command-line application to optimize vectors.",
favicon: "img/favicon.ico",
url: "https://svgo.dev",
baseUrl: "/",
Expand All @@ -32,7 +32,7 @@ const config = {
i18n: {
defaultLocale: "en",
locales: [
"en"
"en"
],
},
markdown: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function Home() {
return (
<Layout>
<Head>
<meta name="description" content="SVGO is a Node.js library and command-line application to optimize vectors."/>
<meta name="description" content="SVGO is a Node.js library and command-line application for optimizing vectors."/>
</Head>
<HomepageHeader />
<main>
Expand Down
34 changes: 27 additions & 7 deletions src/plugins/configure-svgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,33 @@ function configureSvgo() {
});

const svgoConfig = rule.oneOf[0].use[0].options.svgoConfig;
svgoConfig.plugins.push({
name: "prefixIds",
params: {
delim: "",
prefix: (_, info) => path.parse(info.path).name
}
});
svgoConfig.plugins = [
{
...svgoConfig.plugins[0],
params: {
overrides: {
...svgoConfig.plugins[0].params.overrides,
mergePaths: {
noSpaceAfterFlags: true
}
}
}
},
{
name: "prefixIds",
params: {
delim: "",
prefix: (_, info) => path.parse(info.path).name
}
},
{
name: "removeXlink",
params: {
includeLegacy: true
}
},
"removeXMLNS"
];

return {
mergeStrategy: {
Expand Down
6 changes: 3 additions & 3 deletions src/vectors/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/vectors/svgo_hackerman.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/vectors/svgo_integrations.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/vectors/svgo_oss.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/vectors/svgo_trixie.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading