-
Notifications
You must be signed in to change notification settings - Fork 86
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
Please create a new version to support svgo 2.x #156
Comments
Please @visualfanatic |
What I did for SVGO 2.x support is just chaining svgo-loader, before passing to vue-svg-loader, and set At that point the only thing this package does is wrap the SVG in
|
@Excalibaard Can you please show exactly how you did it? Would like to do it your way so I can get rid of this package since @visualfanatic has stopped maintaining or responding for a long time3. |
@Excalibaard is your solution for Vue2 or Vue3? Because looking at the latest
https://github.com/visualfanatic/vue-svg-loader/blob/dev/index.js#L16-L18 |
@rightaway Easiest solution is to pick a different package that's actively maintained, though it has a different way to use it:
EDIT: This package also relies on SVGO 1.x. Otherwise, you can still use this package, but without the svgo part. The below example shows importing SVG as component using the 'inline' query, for example // webpack.config.js
module.exports = {
...,
module: {
rules: [
{
test: /\.svg$/,
resourceQuery: /inline/,
use: [
{
loader: 'vue-loader'
},
{
loader: 'vue-svg-loader',
options: {
svgo: false,
}
},
{
loader: 'svgo-loader',
options: {
// configFile: false // uncomment if not using a svgo.config.js file in your project root
.... // add your svgo options here
}
}
]
},
{
test: /\.svg$/,
use: [
{
loader: 'file-loader'
},
{
loader: 'svgo-loader'
},
]
}
]
}
} or with VueCLI: // vue.config.js
module.exports = {
chainWebpack: (config) => {
const svgRule = config.module.rule('svg');
svgRule.uses.clear();
svgRule
.test(/\.svg$/)
.oneOf('inline')
.resourceQuery(/inline/)
.use('vue-loader')
.loader('vue-loader')
.end()
.end()
.use('vue-svg-loader')
.loader('vue-svg-loader')
.options({
svgo: false
})
.end()
.end()
.use('svgo-loader')
.loader('svgo-loader')
.options({
// configFile: false // uncomment when you have no svgo.config.js at project root
.....
})
.end()
.end()
.oneOf('normal')
.use('file-loader')
.loader('file-loader')
.end()
.end()
.use('svgo-loader')
.loader('svgo-loader')
.end()
.end()
}
} The solution I ended up using in that codebase was to make a folder specifically for my custom loaders, and making sure it's added to webpack's // webpack.config.js
module.exports = {
//...
resolveLoader: {
modules: [
'node_modules',
path.resolve(__dirname, 'loaders') // [workspaceRoot]/loaders
]
}
}; Then, create the file
Then, add the Here's a gist of the loader I used that replaces both svgo-loader and vue-svg-loader.. @darrinmn9 You're correct, if you use Vue 2 you may need to add |
@Excalibaard vue-svg-inline-loader is not actively maintained. |
@ChrisRoss5 You're correct. It has been updated more recently, but also uses SVGO 1.x. I'll remove that recommendation. |
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
* 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
The dev branch seems to support svgo 2.x now, could you please help build a new package to npm?
The text was updated successfully, but these errors were encountered: