-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
gatsby-plugin-netlify output file prefixes assetPath on page urls #26899
Comments
Additional detail. If both assetsPrefix and pathPrefix are set on page URLs (e.g. It would appear to me that the asset prefix should not be on the page URL reference, but should be referenced in the link headers.
|
To add a bit of community urging, I discovered this on our site, because gatsby-plugin-mdx uses There is a similarly bewildered issue in #21462. It seems as though this has been the behavior from the start, wherein |
@cameronmcefee hello! It is very hard to get to the root of the issue, unless there's something "I" (aka the Gatsby team) can play around with. (aka reproduction super appreciated and valuable!) In general, yes, assetPrefix (which I helped build!) was intended to be a full URL, a la the intended use case was for users of Gatsby who want to host their assets (basically, everything besides HTML) on a longer-lived CDN, whereas just the HTML can be deployed separately. Mostly, yes, this was how it was designed, but I'm curious -- it doesn't seem like the issue is the order here (correct me if I misstate) but rather the fact that the MDX plugin seems to be treating links to HTML as if they needed to include an asset prefix, when they (in this case?) in fact don't? (I actually think your issue @cameronmcefee is probably the same as #21462 based on what you've said!) |
Thanks for the 👀 @DSchau and sorry, I look like a rube. I opted for this thread since there are collaborators discussing the issue here, despite meta-issue being different. Here's a reproducible case illustrating the issue: https://github.com/cameronmcefee/assetprefix-kerfuffle. I'm happy to take my discussion over to the other thread since the example is MDX. However. the topic itself I believe is the relationship between Edit: upon further investigation, in my example I discovered that the property |
I cannot get path prefix to work as directed on this page: After CLEAN, all it does is move the static assets over to the subdir, but not the app level JS CSS etc. Those are all at the root and give a 404. |
Closing as we don't own gatsby-plugin-netlify anymore |
Description
Update - I missed the fact that
assetPath
is expected to by a url and not just a path - I think the key question stands - should page urls have a assetPath prefix?When trying to segment the hosting of pages vs CDN assets using the gatsby-config#assetPath feature, the plugin
gatsby-plugin-netlify
outputs file prefixesassetPath
on page URLs.I believe that
assetPrefix
is only supposed to apply to the CSS and JS assets built by Gatsby. In this case, the plugin behavior seems to be treating theassetPrefix
more like thepathPrefix
configuration option. I would expect that the HTML page references listed in_headers
would not contain theassetPrefix
The path for
/page-2/
is the test page shown below.See codesandbox: https://codesandbox.io/s/gatsby-netlify-asset-prefix-jd5rc?file=/gatsby-config.js
/app-140865cdb6a305440c80.js
) contain the prefix for their cache-control settings?Steps to reproduce
Create starter project
add
gatsby-plugin-netlify
add plugin to
gatsby-config.js
define
assetPrefix
to gatsby-config.jsyarn gatsby build --prefix-paths
to produce a./public
build with a_headers
output filecat ./public/_headers
Expected result
File reduced for brevity
Actual result
File reduced for brevity - note entry
/customAssetPrefix/page-2/
second from last lineEnvironment
The text was updated successfully, but these errors were encountered: