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

svg-sprite-loader not working well with encore webpack #506

Open
baloo1687 opened this issue Oct 2, 2023 · 0 comments
Open

svg-sprite-loader not working well with encore webpack #506

baloo1687 opened this issue Oct 2, 2023 · 0 comments

Comments

@baloo1687
Copy link

According to doc:
Default browser runtime example

All what i need to do - add import in my app.js and write id in use tag:

app.js:

import delivery from '../images/svg/icons/delivery.svg';

webpack.config.js:

  .addRule({
    test: /\.svg$/,
    use: [{
        loader: 'svg-sprite-loader',
        options: {
            extract: false, // Extract the sprite into its own file
        }
    }, 'svgo-loader'] // Optionally, you can use svgo-loader to optimize SVG files
  })

base.html.twig:

    <svg>
      <use xlink:href="#delivery"></use>
    </svg>

but nothing's happening.

One more thing, ur examples is not full, pls rewrite this examples if it's possible...

I trying to use spriteModule, as well. But I getting empty svg tag:

image
import BrowserSprite from 'svg-baker-runtime/src/browser-sprite';
import domready from 'domready';
import '../images/svg/icons/delivery.svg';

const sprite = new BrowserSprite();

domready(() => sprite.mount('#sprite-icons-custom'));

export default sprite; // don't forget to export!

But if I will use

sprite.add(delivery);

I getting error:

sprite.js:71 Uncaught TypeError: s.stringify is not a function
    at sprite.js:71:1
    at Array.map (<anonymous>)
    at BrowserSprite.stringify (sprite.js:71:1)
    at BrowserSprite.render (browser-sprite.js:220:17)
    at BrowserSprite.mount (browser-sprite.js:202:1)
    at icons-sprite.js:9:23

code:

import BrowserSprite from 'svg-baker-runtime/src/browser-sprite';
import domready from 'domready';
import delivery from '../images/svg/icons/delivery.svg';

const sprite = new BrowserSprite();

sprite.add(delivery);

domready(() => sprite.mount('#sprite-icons-custom'));

export default sprite; // don't forget to export!
  • Node.js version: v20.3.0
  • webpack version: 5.74.0
  • svg-sprite-loader version: 6.0.11
  • OS type & version: MacOs Ventura
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

No branches or pull requests

1 participant