Skip to content

Commit

Permalink
feat: support importPathTransform config, close #9
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 25, 2021
1 parent 329156d commit 79b101f
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 47 deletions.
3 changes: 2 additions & 1 deletion example/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"typescript": "^4.1.5",
"vite": "^2.0.2",
"vite-plugin-components": "workspace:*",
"vite-plugin-md": "^0.5.1"
"vite-plugin-md": "^0.5.1",
"vite-plugin-vue-svg": "^0.1.0"
}
}
1 change: 1 addition & 0 deletions example/basic/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<div class="block">
<h1>Custom Resolvers (1)</h1>
<MyCustom />
<CarbonSvg />
</div>

<div class="block">
Expand Down
7 changes: 7 additions & 0 deletions example/basic/src/components/CarbonSvg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion example/basic/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UserConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import ViteComponents from 'vite-plugin-components'
import Markdown from 'vite-plugin-md'
import SVG from 'vite-plugin-vue-svg'

const config: UserConfig = {
alias: {
Expand All @@ -13,10 +14,12 @@ const config: UserConfig = {
include: [/\.vue$/, /\.md$/],
}),
Markdown(),
SVG(),
ViteComponents({
extensions: ['vue', 'md'],
extensions: ['vue', 'md', 'svg'],
directoryAsNamespace: true,
globalNamespaces: ['global'],
importPathTransform: path => path.endsWith('.svg') ? `${path}?component` : undefined,
customLoaderMatcher: path => path.endsWith('.md'),
customComponentResolvers: [
(name) => {
Expand Down
Loading

0 comments on commit 79b101f

Please sign in to comment.