JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.02k stars 270 forks source link

feat(outputPath): add possibility to define output path #396

Closed Slashgear closed 4 years ago

Slashgear commented 4 years ago

What kind of change does this PR introduce? (bugfix, feature, docs update, improvement)

What is the current behavior? (You can also link to an open issue here)

We could only define a public path (ie: Browser path to get the generated file)

What is the new behavior (if this is a feature change)?

Many loader allow to manage this feature, that's why I suggest it. Does this PR introduce a breaking change?

Nope, made it retrocompatible because this param is not required.

Please check if the PR fulfills contributing guidelines

kisenka commented 4 years ago

@Slashgear thanks for PR! How this option differs from publicPath?

Slashgear commented 4 years ago

@kisenka How this option differs from publicPath?

In webpack world:

Those two could be the same and you would use only a publicPath, but in some cases, you need to be able to define a different path.

Imagine a webpack generated output like this.

dist/
  public/
     assets/
        sprite.svg
  server.js

I want to generate an output file in the public/assets/sprite.svg path but I only want to open public files to the web by rewriting URL in order to hide my server.js file.

You would use

{
  "outputPath":"public/assets/",
  "publicPath":"/assets/",
}
kisenka commented 4 years ago

Got it! Could you please add test case for your changes? It can be based on this one case.

kisenka commented 4 years ago

Shipped in svg-sprite-loader@4.3.0