Skip to content

Commit

Permalink
Adding inline alias
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsanos committed May 23, 2023
1 parent 351de45 commit ca8c483
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions examples/vue-ts/index.d.ts
Expand Up @@ -10,6 +10,12 @@ declare module '*.svg?component' {
export default src
}

declare module '*.svg?inline' {
import { FunctionalComponent, SVGAttributes } from 'vue'
const src: FunctionalComponent<SVGAttributes>
export default src
}

declare module '*.svg?url' {
const src: String
export default src
Expand Down
5 changes: 5 additions & 0 deletions examples/vue-ts/src/App.vue
Expand Up @@ -4,6 +4,7 @@ import { defineAsyncComponent } from "vue";
import HelloWorld from "./components/HelloWorld.vue";
import Test from "./assets/test.svg?component";
import TestInline from "./assets/test.svg?inline";
import testUrl from "./assets/test.svg?url";
import testRaw from "./assets/test.svg?raw";
Expand All @@ -16,6 +17,10 @@ const Async = defineAsyncComponent(() => import(`./assets/${name}.svg`));
<Test class="test-svg" />
</div>

<div id="component">
<TestInline class="test-svg" />
</div>

<div id="image">
<img src="./assets/test.svg?url">
</div>
Expand Down
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -5,7 +5,7 @@ const { optimize: optimizeSvg } = require('svgo')
module.exports = function svgLoader (options = {}) {
const { svgoConfig, svgo, defaultImport } = options

const svgRegex = /\.svg(\?(raw|component|skipsvgo))?$/
const svgRegex = /\.svg(\?(raw|component|skipsvgo|inline))?$/

return {
name: 'svg-loader',
Expand Down

0 comments on commit ca8c483

Please sign in to comment.