Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks when Webpack's output.publicPath is a URL #153

Closed
kennethlmartin opened this issue Nov 17, 2018 · 2 comments
Closed

Breaks when Webpack's output.publicPath is a URL #153

kennethlmartin opened this issue Nov 17, 2018 · 2 comments

Comments

@kennethlmartin
Copy link

When output.publicPath in webpack is a URL, as is the case when using a CDN, the returned script tags from extractor.getScriptTags have broken src URLs with a slash being removed from the protocol.

If the below is set in webpack.

webpackConfig = {
  //...
  output: {
    publicPath: 'https://cdn.example.com/assets/',
  }
};

then extractor.getScriptTags() will return.

<script>window.__LOADABLE_REQUIRED_CHUNKS__ = ["loadable-example"];</script>
<script async data-chunk="loadable-example" src="https:/cdn.example.com/assets/loadable-example.js"></script>
<script async data-chunk="main" src="https:/cdn.example.com/assets/main.js"></script>
@patrickhaug
Copy link
Contributor

It's because of this util fn

export const joinURLPath = (...paths) => paths.join('/').replace(/\/\//g, '/')
I guess it's there to strip a trailing slash in the public path? Or is there another purpose?

@kennethlmartin
Copy link
Author

ahhh... okay so that should probably be something like this instead:

export const joinURLPath = (...paths) => paths.join('/').replace(/([^:]\/)\/+/g, '$1');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants