swisnl/vue-cli-plugin-svg-sprite

how i inject style in sprite

x-amer-ngmx opened this issue · 4 comments

Hi! I need to import stylus Style from all my VSG.

I do This:

vue.config.js

{
  pluginOptions: {
    svgSprite: {
      dir: path.resolve(__dirname, 'src/assets/svg'),
      test: /\.(svg)(\?.*)?$/,
      loaderOptions: {
        stylus: {
          import: [path.resolve(__dirname, "src/assets/style/svg")]
        },
        extract: true,
        spriteFilename: 'img/icons.[hash:8].svg' // or 'img/icons.svg' if filenameHashing == false
      },
      pluginOptions: {
        plainSprite: true
      }
    }
  },
}

But it's not worked (((

JaZo commented

Hi @x-amer-ngmx, loaderOptions refers to the options of the underlying svg-sprite-loader package, you can't add extra loaders that way. If you like to add custom loaders for your SVG's, you have to fiddle with the Webpack config. Please see the vue-cli docs for more information.

JaZo commented

More information about adding extra loaders: https://github.com/swisnl/vue-cli-plugin-svg-sprite#extra-loaders

Yes, thanks, I already figured it out. 👌
And do not tell me how to embed the sprite in the html index 😢

JaZo commented

You can set extract: false to let the sprite be automatically injected in the document body.