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

Custom input path outside the nuxt 3 app doesn't work #281

Open
jfernandezpe opened this issue Apr 12, 2023 · 2 comments · May be fixed by #282
Open

Custom input path outside the nuxt 3 app doesn't work #281

jfernandezpe opened this issue Apr 12, 2023 · 2 comments · May be fixed by #282

Comments

@jfernandezpe
Copy link

jfernandezpe commented Apr 12, 2023

Hi,

I use svg-sprite-module in a couple of Nuxt 2 apps in a monorepo andboth apps share the same svgs so with svgSprite.input option I point to the asset package and it works.

Now I'm creating a new Nuxt 3 app in the monorepo and it seems that the same strategy doesn't work, the icons do not load in the nuxt 3 app. After some debugging, I found that svg-sprite-module uses nitro's storage layer to deal with the filesystem. And because I'm pointing to a folder outside nitro's scope, svgSprite cannot the shared SVGs.

Am I doing something wrong? May you suggest any workaround? I would be happy to write a fix to this issue and send you a pull request but I'm not sure where to start.

I create a basic reproduction scenario, without configuring lerna or yarn workspaces: https://github.com/jfernandezpe/svg-sprite-module-error-reproduction

Thank you for your time!

@farnabaz
Copy link
Collaborator

Hey @jfernandezpe
Feel free to open a PR to resolve this 👍
Looking forward to seeing your improvements 🙂

@obulat obulat linked a pull request Jun 13, 2023 that will close this issue
@smoglica
Copy link

A possible workaround could be by playing with alias. Config example:

import { join } from 'path';
import { defineNuxtConfig } from 'nuxt/config';

export default defineNuxtConfig({
	srcDir: 'src/',
	modules: ['@nuxtjs/svg-sprite'],
	svgSprite: {
		input: '~/src/assets/sprite/svg',
		output: '~/src/assets/sprite/gen'
	},
	alias: {
		'~/src/assets/sprite/gen': join(__dirname, 'src/assets/sprite/gen'),
	}
});

up for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants