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

Dynamic hostname publicPath feature (from --target lib config) is broken for early resolved resources #1253

Closed
doublemarked opened this issue May 9, 2018 · 0 comments
Labels

Comments

@doublemarked
Copy link

doublemarked commented May 9, 2018

Version

3.0.0-beta.9

Reproduction link

https://github.com/doublemarked/vue-libconf-issues

Steps to reproduce

  1. git clone https://github.com/doublemarked/vue-libconf-issues.git
  2. npm install && npm run build && npm run demo
  3. Load http://localhost:8000
  4. Observe errors in browser console

What is expected?

The library entry code sports the excellent idea of assigning Webpack's publicPath at runtime to allow modules to be used cross domain / webroot. Per the comments in resolveLibConfig.js:

  // use dynamic publicPath so this can be deployed anywhere
  // the actual path will be determined at runtime by checking
  // document.currentScript.src.

It is expected that the dynamic publicPath should be resolved early enough to apply to all resource loading.

What is actually happening?

That functionality, implemented in entry-lib.js, unfortunately does not run early enough to affect resources that are loaded as part of the initial code chunk. It seems to currently only work if you call import() later, after initial load.


Context: In my real-world project this bug is preventing me from loading CSS in my library and having webpack properly resolve the hostname for the bundled assets (fonts, images, etc).

@doublemarked doublemarked changed the title Dynamic hostname publicPath feature (from --target lib config) is broken for non-lazy imports Dynamic hostname publicPath feature (from --target lib config) is broken for early resolved resources May 9, 2018
@yyx990803 yyx990803 added the bug label May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants