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

Adding inline alias #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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