Closed max-mykhailenko closed 8 years ago
I know that I something like this
__svg__.filename = `public/web/${__svg__.filename}`;
but this solution will require my attention every time when I change public path
@max-mykhailenko Hi, you can use https://github.com/webpack/docs/wiki/list-of-plugins#defineplugin for defining you public path or hostname
And, actually you can override webpack-svgstore-plugin/src/helpers/svgxhr
I can't add port as part of __svg__.filename
, you add slashes and I got http://rgb-lab.dev/:3000/public/web/icons/sprite.svg
All paths is relative publicPath
require('webpack-svgstore-plugin/src/helpers/svgxhr')({
filename: 'http://yourhostname:port/additional/path/' + __svg__.filename
});
'http://yourhostname:port/additional/path/'
— it's dynamic part and I can't set it static.
@max-mykhailenko is host depends by environment? or build/hash number? Can you explain your problem more detail?
Page url and port aren't static. Several examples:
Production: http://site.com
Dev: site url http://site.dev
, express server url for hot reloading http://site.dev:3000
Dev with sharing url: site url http://192.168.1.10
, express server url for hot reloading http://192.168.1.10:3000
In webpack DefinePlugin I can define variable for dev and production related to NODE.ENV, but I can't check url.
I want to dynamically write url and port to filename ilke this url+port+publicPath+svg.filename
Maybe code is ugly but it's allow to add webpack public path to filename dynamically like this:
Default request was:
http://rgb-lab.dev/icons/sprite.svg
I need request to:http://rgb-lab.dev:3000/public/web/icons/sprite.svg
My public path is:/public/web/
Before modifications and with using__webpack_public_path__
I have request to:http://rgb-lab.dev/http://rgb-lab.dev:3000/public/web/icons/sprite.svg