Skip to content

Commit 0fe62a5

Browse files
committed
Add Vue 3 support
1 parent d6bce85 commit 0fe62a5

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const SVGO = require('svgo');
22
const { getOptions } = require('loader-utils');
3+
const { version } = require('vue');
4+
const { major } = require('semver')
35

46
module.exports = async function (svg) {
57
const callback = this.async();
@@ -18,5 +20,9 @@ module.exports = async function (svg) {
1820
}
1921
}
2022

21-
callback(null, `<template>${svg.replace('<svg', '<svg v-on="$listeners"')}</template>`)
23+
if (major(version) === 2) {
24+
svg = svg.replace('<svg', '<svg v-on="$listeners"');
25+
}
26+
27+
callback(null, `<template>${svg}</template>`)
2228
};

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
"author": "Damian Stasik <[email protected]>",
2121
"main": "index.js",
2222
"dependencies": {
23-
"loader-utils": "^2.0.0"
23+
"loader-utils": "^2.0.0",
24+
"semver": "^7.3.2"
2425
},
2526
"devDependencies": {
2627
"vue-tabs-component": "^1.5.0",
2728
"vuepress": "^1.5.3"
29+
},
30+
"peerDependencies": {
31+
"vue": "^2.5.0 || ^3.0.0-0"
2832
}
2933
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6459,6 +6459,11 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.2.0, semver@^6.3.0:
64596459
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
64606460
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
64616461

6462+
semver@^7.3.2:
6463+
version "7.3.2"
6464+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
6465+
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
6466+
64626467
64636468
version "0.17.1"
64646469
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"

0 commit comments

Comments
 (0)