svg-sprite-loader
svg-sprite-loader copied to clipboard
publicPath not work as expected
Do you want to request a feature, report a bug or ask a question? Bug What is the current behavior? publicPath was added to output file path of sprite.svg What is the expected behavior? publicPath should not be added to the path of sprite.svg
If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code. The best way is to create repo with minimal setup to demonstrate a problem (package.json, webpack config and your code). It you don't want to create a repository - create a gist with multiple files It's easy to reproduce, I had config like below
options: {
symbolId: '[name]-[hash:8]',
publicPath: 'http://localhost:8000/',
spriteFilename: 'media/sprite.[hash:8].svg',
extract: true,
}
and the output file structure

Please tell us about your environment:
- Node.js version: 10.0.0
- webpack version: 4.29.0
- svg-sprite-loader version: 4.1.3
- OS type & version: ubuntu 16.04
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
I dive deep into the source code of plugin.js and found
const filenamePrefix = this.rules.publicPath
? this.rules.publicPath.replace(/^\//, '')
: '';
compilation.assets[`${filenamePrefix}${filename}`] = {
source() { return content; },
size() { return content.length; }
};
I think there is no need to add this.rules.publicPath to filenamePrefix.
+1