Giter Site home page Giter Site logo

Comments (6)

bensampaio avatar bensampaio commented on July 29, 2024

Could you describe your use case so that I know why this change is necessary?

from external-svg-sprite-loader.

satazor avatar satazor commented on July 29, 2024

The strategy that this plugin uses does not allow the sprite file to be served via cross-domain request, see #37. Because of that, we must pass a non-CDN URL as the publicPath to external-svg-sprite-loader.

In our projects, we produce a manifest.json that contains all the asset URLs and use them to load JS and CSS files as well as prefetching/preloading assets. But since we are changing the publicPath of the external-svg-sprite-loader to be a non-CDN url, we must ensure that the URL for each sprite file present in the manifest.json are correct. More specifically, the URLs of the sprite must not use the webpack publicPath config but instead the URL that pass to external-svg-sprite-loader (non-CDN url).

To accomplish this, we need to get access to the produced sprites after a webpack build.

Hope this makes things clearer.

from external-svg-sprite-loader.

satazor avatar satazor commented on July 29, 2024

I've edited my comment to be more complete.

from external-svg-sprite-loader.

bensampaio avatar bensampaio commented on July 29, 2024

Hmm I understand the problem. Are you also using webpack-manifest-plugin? Maybe there is a way of communicating a different publicPath to other plugins? Maybe we can set some webpack property in order to change the path for a specific chunk. Have you looked into that? Maybe we can even find other plugins with a similar problem? Would be interesting to know if that's actually possible. The solution you proposed on the PR might work but feels a bit like a workaround to something that might have a better solution.

from external-svg-sprite-loader.

satazor avatar satazor commented on July 29, 2024

We are not using webpack-manifest-plugin but we are doing something similar. Some plugins, such as external-svg-sprite-loader, support overriding the publicPath. Though, this publicPath override is not available in Webpack stats/compilation objects directly, which are used by ourselves and webpack-manifest-plugin.

Because of this reason, webpack-manifest-plugin offers options.map and options.generate to allow consumers to change assets, including their URL. Though, we need to know which assets were produced by the external-svg-sprite-loader. One could obviously search for assets by a prefix, e.g.: svg-sprite-*, but it would be a poor solution because one could simply change the name to something else. That's why I made #42.

Another way that would solve my issue, but it's not a convention, is to add a publicPath getter here which I would call on my side. This method would return the publicPath of each sprite. To do this correctly, we would also need to be able to set/get the public path on the SvgSprite class. Note that this solution still requires me to the assets for each sprite.

from external-svg-sprite-loader.

satazor avatar satazor commented on July 29, 2024

Bump.

from external-svg-sprite-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.