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

fix: process with plugin raw svg #117

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions index.js
@@ -1,5 +1,5 @@
const fs = require('fs').promises
const { compileTemplate } = require('vue/compiler-sfc')
const { compileTemplate } = require('@vue/compiler-sfc')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { compileTemplate } = require('@vue/compiler-sfc')
const { compileTemplate } = require('vue/compiler-sfc')

const { optimize: optimizeSvg } = require('svgo')

module.exports = function svgLoader (options = {}) {
Expand Down Expand Up @@ -33,17 +33,17 @@ module.exports = function svgLoader (options = {}) {
return
}

if (importType === 'raw') {
return `export default ${JSON.stringify(svg)}`
}

if (svgo !== false && query !== 'skipsvgo') {
svg = optimizeSvg(svg, {
...svgoConfig,
path
}).data
}

if (importType === 'raw') {
return `export default ${JSON.stringify(svg)}`
}

// To prevent compileTemplate from removing the style tag
svg = svg.replace(/<style/g, '<component is="style"').replace(/<\/style/g, '</component')

Expand Down