Skip to content

Commit

Permalink
refactor: πŸ’‘ change config key from 'svgoOptions' to 'svgo' (#36)
Browse files Browse the repository at this point in the history
* refactor: πŸ’‘ change nuxt config key from 'svgoOptions' to 'svgo'

BREAKING CHANGE: 🧨 Nuxt config key is now 'svgo', instead of 'svgoOptions'

* chore: πŸ€– changeset

* chore: πŸ€– update playground to use new 'svgo' config key

* fix: πŸ› use svgo-loader to run svgo with options with webpack

As discussed in
damianstasik/vue-svg-loader#156,
'vue-svg-loader' uses svgo v1. That project looks to be unmaintained,
with the latest beta release more than 2 years old. This PR disables the
svgo functionality of vue-svg-loader, instead relying on svg/svgo-loader
to perform optimizations, essentially making vue-svg-loader wrap the svg
content in template tags.

βœ… Closes: #37

* docs: ✏️ update README with webpack-based tooling info

* docs(changeset): fix webpack SVG optimization with svgo-loader
  • Loading branch information
cpsoinos authored Jun 23, 2022
1 parent a3bfd82 commit a6c8ca0
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-stingrays-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nuxt-svgo': major
---

Change Nuxt config key from 'svgoOptions' to 'svgo'. If you were using customized SVGO options, you'll need to update your `nuxt.config.ts` file to use `svgo` as the options key rather than `svgoOptions`. If you were using the default SVGO options, no change is necessary.
5 changes: 5 additions & 0 deletions .changeset/serious-rules-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nuxt-svgo': minor
---

fix webpack SVG optimization with svgo-loader
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ If your Nuxt app uses Vite, this module adds [vite-svg-loader](https://github.co

### Webpack

If your Nuxt app uses Webpack, this module adds [vue-svg-loader](https://github.com/damianstasik/vue-svg-loader) to the underlying Webpack configuration. All due credit for `vue-svg-loader` to its author, [@damianstasik](https://github.com/damianstasik).
If your Nuxt app uses Webpack, this module adds [vue-svg-loader](https://github.com/damianstasik/vue-svg-loader) and [svgo-loader](https://github.com/svg/svgo-loader) to the underlying Webpack configuration. As discussed in [this issue](https://github.com/damianstasik/vue-svg-loader#156), `vue-svg-loader` uses version 1 of SVGO. `vue-svg-loader` looks to be unmaintained, with the latest beta release more than 2 years old. We disable the SVGO functionality of `vue-svg-loader`, instead relying on `svgo-loader` to perform optimizations, essentially making `vue-svg-loader` wrap the svg content in `<template></template>` tags.

All due credit for `vue-svg-loader` to its author, [@damianstasik](https://github.com/damianstasik).
All due credit for `svgo-loader` to its author, [@svg](https://github.com/svg).

## Configuration

Expand All @@ -76,7 +79,7 @@ import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
modules: ['nuxt-svgo'],
svgoOptions: {
svgo: {
svgoConfig: {
multipass: true,
removeViewBox: false,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
},
"dependencies": {
"@nuxt/kit": "npm:@nuxt/kit-edge@latest",
"svgo-loader": "^3.0.1",
"vite-svg-loader": "^3.3.0",
"vue-loader": "^17.0.0",
"vue-svg-loader": "0.17.0-beta.2"
Expand Down
2 changes: 1 addition & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import NuxtSVGO from '..'

export default defineNuxtConfig({
modules: [NuxtSVGO],
svgoOptions: {
svgo: {
svgo: true,
defaultImport: 'component'
}
Expand Down
Loading

0 comments on commit a6c8ca0

Please sign in to comment.