swisnl / vue-cli-plugin-svg-sprite

vue-cli 3 plugin to build an SVG sprite
MIT License
68 stars 11 forks source link

how i inject style in sprite #13

Closed x-amer-ngmx closed 1 year ago

x-amer-ngmx commented 1 year ago

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 1 year ago

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 1 year ago

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

x-amer-ngmx commented 1 year ago

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

JaZo commented 1 year ago

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