diff --git a/.changeset/small-pianos-work.md b/.changeset/small-pianos-work.md new file mode 100644 index 0000000..40b42ee --- /dev/null +++ b/.changeset/small-pianos-work.md @@ -0,0 +1,5 @@ +--- +"@mcansh/vite-svg-sprite-plugin": patch +--- + +re-add virtual module support diff --git a/examples/remix/app/routes/_index/route.tsx b/examples/remix/app/routes/_index/route.tsx index 3210a8d..b91fae5 100644 --- a/examples/remix/app/routes/_index/route.tsx +++ b/examples/remix/app/routes/_index/route.tsx @@ -3,6 +3,7 @@ import archiveBoxArrowDownIconHref from "~/assets/archive-box-arrow-down.svg"; import beakerIconHref from "heroicons/24/outline/beaker.svg"; import eyeIconHref from "lucide-static/icons/eye.svg"; import homeIconHref from "lucide-static/icons/home.svg"; +import spriteUrl from "virtual:@mcansh/vite-svg-sprite-plugin"; import { Icon } from "./icon"; export const meta: MetaFunction = () => { @@ -16,6 +17,7 @@ export default function Index() { return (

Welcome to Remix

+

{spriteUrl}

diff --git a/examples/remix/vite.config.ts b/examples/remix/vite.config.ts index cef259d..c2e24bd 100644 --- a/examples/remix/vite.config.ts +++ b/examples/remix/vite.config.ts @@ -12,7 +12,7 @@ export default defineConfig({ tsconfigPaths(), createSvgSpritePlugin({ logging: true, - spriteOutputName: "some-file.svg", + spriteOutputName: "mysvgsprite.svg", }), ], }); diff --git a/packages/vite-svg-sprite-plugin/src/index.ts b/packages/vite-svg-sprite-plugin/src/index.ts index 3db6a17..1b8b06e 100644 --- a/packages/vite-svg-sprite-plugin/src/index.ts +++ b/packages/vite-svg-sprite-plugin/src/index.ts @@ -136,8 +136,8 @@ export function createSvgSpritePlugin(configOptions?: Config): Array { async load(id) { if (id === resolvedVirtualModuleId) { - warn(`the virtual module has been temporarily disabled`); - return js`export default "";`; + let spriteUrl = `/${config.build.assetsDir}/${options.spriteOutputName}`; + return js`export default ${JSON.stringify(spriteUrl)}`; } },