Using file-loader with __webpack_public_path__? #125
Comments
Hey, was having the same issue but was able to work it out for my use case. This didn't work // index.js
__webpack_public_path__ = '...';
.
.
.
import Main from '.../Main'; However this did: // setPublicPath.js
__webpack_public_path__ = '...'; // index.js:
import './setPublicPath';
.
.
.
import Main from '.../Main';
... All the ES6 imports were ran before any actual code, regardless of order, so the URLs in any (recursively) imported files were resolved before the public path was set. So setting the public path in another import before any other imports ensured the correct path for everything else. Hope this helps. |
That doesn't work for me. I'm curious if anyone else has this issue. |
|
@reywright webpack/webpack#2776 |
actually, the |
@lili21 what I'm saying is I need to specify the publicPath because the publicPath doesn't work otherwise. I've seen those threads you're talking about... I'll try them again but I remember trying them already. |
I thought what you need is |
I don't. I'm only using it because webpack_public_path isn't working |
update to latest version . and It will work. |
I think this is due to webpack/webpack#3265 (comment). |
Using the latest version of file-loader. The following works for me:
file-loader?name=img/[name].[ext]&emitFile=false&publicPath=/xyz/
Because the publicPath for my application can vary wildly, I can't hardcode the publicPath in the webpack config. I'd like if the file-loader used
__webpack_public_path__
or had some option like [webpack_public_path] or basically any hook I could use to be able to let my backend specify what the publicPath is.Any ideas? Is this something I can get around for now? I feel like this is either a bug, or a feature, or a question... I don't know enough to say.
The text was updated successfully, but these errors were encountered: