dschewchenko / nuxt-svgicon

MIT License
6 stars 4 forks source link

Support Nuxt configurations with 'srcDir' option set #5

Closed FloEdelmann closed 1 year ago

FloEdelmann commented 5 years ago

Nuxt.js allows users to have all Nuxt files in a subdirectory with the srcDir option. When this option is set, nuxt-svgicon build fails.

Example

nuxt.config.js:

module.exports = {
  srcDir: "./ui/",
  modules: [
    ["nuxt-svgicon", {
      sourcePath: "ui/assets/icons",
      targetPath: "ui/assets/icons/bundle"
    }]
  ],
  // ...
};

Generating the icon components in the correct location works. However, the build fails because it can't resolve the module ~/ui/assets/icons/bundle (because ~ already resolves to ui). I tracked the failing import down to svgicon.template.js.

With the fix from this PR, that template now only receives the distPath assets/icons/bundle, so it can safely prepend ~/.

dschewchenko commented 5 years ago

Thanks for fix. Why you don't use svg-sprite-module from nuxt-comunity? It's more optimized and fast. It's the same as my planned second version 😂

FloEdelmann commented 5 years ago

I've looked at that module, but since the sprite is not embedded into the page directly, it's another HTTP request that can easily be avoided. Is there any chance this repository in it's current form will continue to be supported?

dschewchenko commented 5 years ago

May be not. I will PR to their module. Because all my planned features are there :)

dschewchenko commented 5 years ago

First PR will be inlineing to html

dschewchenko commented 5 years ago

But we may to wait some time, because I'm hard woking now