Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

[v1.1.8] publicPath does not work with protocol/absolute URLs #252

Closed
antokara opened this issue Feb 21, 2018 · 6 comments
Closed

[v1.1.8] publicPath does not work with protocol/absolute URLs #252

antokara opened this issue Feb 21, 2018 · 6 comments

Comments

@antokara
Copy link

I could be misusing this option but up to/including 1.1.7,
using the publicPath for absolute URLs like publicPath: "https://my.cdn/" was possible.

In 1.1.8 due to this change:
26e47ca#diff-1fdf421c05c1140f6d71444ea2b27638R46
(replacing concat with path.join)
it is not possible and the // characters are getting replaced with one / rendering the absolute URL invalid...

Is there another way to configure CDN / custom absolute URLs?
ie. I want to serve some files from a different protocol/host than the rest of the app...

@aptx4869
Copy link

aptx4869 commented Feb 21, 2018

It also breaks webpack-dev-server.
http://localhost:8080/fontello.woff => http://localhost:8080/localhost:8080/fontello.woff

@michael-ciniawsky michael-ciniawsky added this to the 1.1.9 milestone Feb 21, 2018
@michael-ciniawsky michael-ciniawsky changed the title publicPath does not work with absolute URLs in 1.1.8 [v1.1.8] publicPath does not work with protocol/absolute URLs Feb 21, 2018
@jRichardeau
Copy link

It also breaks nested relative path :
publicPath: "my/path" replaced by "my\\path" which is not working on browser.

@WolfspiritM
Copy link

This also breaks our case using url-loader while having output.publicPath set to for example "./lib/":

      {
        test: /\.(gif|png|svg|jpeg|jpg)(\?v=[a-z0-9]\.[a-z0-9]\.[a-z0-9])?$/,
        use: [
            {
                loader: 'url-loader',
                options: {
                    limit: 8192,
                    name: '[name].[ext]',
                    outputPath: 'images/',
                    publicPath: '../'
                }
            }
        ]
      }

Old Version produced: background-image: url(../images/image.jpg);
New Version produces: background-image: url(../image.jpg);
It seems to ignore the outputPath?!

@jRichardeau
Copy link

I think this is not a bug, this is a fix : https://github.com/webpack-contrib/file-loader/releases/tag/v1.1.7
This config should work :

{
      test: /\.(gif|png|svg|jpeg|jpg)(\?v=[a-z0-9]\.[a-z0-9]\.[a-z0-9])?$/,
      use: [
          {
              loader: 'url-loader',
              options: {
                  limit: 8192,
                  name: '[name].[ext]',
                  outputPath: 'images/',
                  publicPath: '../images/'
              }
          }
      ]
    }

But it is a breaking change, should have it been done at least in a minor version ?

@WolfspiritM
Copy link

WolfspiritM commented Feb 21, 2018

Okay thanks.
I assumed that something like that would work but as a patch version change should not break things I expected this to be a bug rather then a fix.

@michael-ciniawsky
Copy link
Member

Released in v1.1.9 🎉

@michael-ciniawsky michael-ciniawsky removed this from the 1.1.10 milestone Feb 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants