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

Fix for relative asset lookup (shouldUseRelativeAssetPaths) #5732

Closed
andys8 opened this issue Nov 6, 2018 · 6 comments
Closed

Fix for relative asset lookup (shouldUseRelativeAssetPaths) #5732

andys8 opened this issue Nov 6, 2018 · 6 comments
Labels

Comments

@andys8
Copy link
Contributor

andys8 commented Nov 6, 2018

Preface

The issue to import e.g. fonts in css #5162 was closed by "Correctly lookup assets when using a relative build directory" #5163. The fix adds this line, to decide whether the feature should be used or not.

const shouldUseRelativeAssetPaths = publicPath === './';

There are comments spread that recommend to set "homepage": "." or "homepage": "./" in package.json. See documentation.

Issue

The application is served under different domains prefixed with a path ("/mypath").
Setting "homepage": "./mypath" was working fine, although I'm not sure if this is supported.

But the fix for assets urls in (s)css will not be applied, because of the condition:

const shouldUseRelativeAssetPaths = publicPath === './';

Fix

We could change the condition and paths will work in the described case.

const shouldUseRelativeAssetPaths = publicPath && publicPath.startsWith('./');
@andys8
Copy link
Contributor Author

andys8 commented Nov 7, 2018

This is how I work around this issue.

  1. Make sure the application is served under /mypath/
  2. Redirect /mypath to /mypath/
  3. Use "homepage": "."

I'll let the issue open to clarify, what the intended behavior should look like and decide if the fix should address the issue, or documentation could be updated.

@andys8
Copy link
Contributor Author

andys8 commented Dec 3, 2018

The same problem appears if react-router is used, so that the application is server under a path, but there is an additional path by the router.

@stale
Copy link

stale bot commented Jan 3, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jan 3, 2019
@andys8
Copy link
Contributor Author

andys8 commented Jan 3, 2019

Any feedback?

@stale stale bot removed the stale label Jan 3, 2019
@stale
Copy link

stale bot commented Feb 7, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Feb 7, 2019
@stale
Copy link

stale bot commented Feb 12, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Feb 12, 2019
@lock lock bot locked and limited conversation to collaborators Feb 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant