-
Notifications
You must be signed in to change notification settings - Fork 394
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
[server] Allow specifying a basePath for a studio #720
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* [server] Allow specifying a basePath for a studio * [default-layout] Resolve and use base path for studio if specified
* [server] Allow specifying a basePath for a studio * [default-layout] Resolve and use base path for studio if specified
* [form-builder] Conflicting name causes radiobuttons not to focus * [components] Styling focus after selectContainer is removed * [form-builder] Requests from PR * [import] Support importing from folder * [core] Allow importing datasets from directory * [core] Improve `sanity dataset import` documentation * [validation] Allow unicode in URIs * [chore] Avoid mixed export/imports (#699) * [image-url] Fix parsing image source (#728) * [image-url] Fix parsing image source * [image-url] Remove only from test case and change comprison operators to triple equal in parseSource * [components] Styling focus state on select (#682) * [server] Allow specifying a basePath for a studio (#720) * [server] Allow specifying a basePath for a studio * [default-layout] Resolve and use base path for studio if specified * [image-url] Code style fixes * v0.128.12 * [cli] Allow using template flag in interactive mode * v0.128.13
* [form-builder] Conflicting name causes radiobuttons not to focus * [components] Styling focus after selectContainer is removed * [form-builder] Requests from PR * [import] Support importing from folder * [core] Allow importing datasets from directory * [core] Improve `sanity dataset import` documentation * [validation] Allow unicode in URIs * [chore] Avoid mixed export/imports (#699) * [image-url] Fix parsing image source (#728) * [image-url] Fix parsing image source * [image-url] Remove only from test case and change comprison operators to triple equal in parseSource * [components] Styling focus state on select (#682) * [server] Allow specifying a basePath for a studio (#720) * [server] Allow specifying a basePath for a studio * [default-layout] Resolve and use base path for studio if specified * [image-url] Code style fixes * v0.128.12 * [cli] Allow using template flag in interactive mode * v0.128.13
Hey I found out it'd be very useful if I could specify the basePath as an option in the build command, because it'll make it much easier to use in CI and build systems (my basePath is different in production/staging). I found how to do it, will probably PR soon. |
@@ -96,7 +97,7 @@ export default async (args, context) => { | |||
const indexStart = Date.now() | |||
spin = output.spinner('Building index document').start() | |||
const doc = await getDocumentElement( | |||
{...compilationConfig, hashes: chunkMap, project: config.get('project')}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding adding the ability to specify basePath as an option in the cli, I was thinking of using it like this:
const doc = await getDocumentElement(
{...compilationConfig, hashes: chunkMap},
{
basePath: flags.basePath || (project && project.basePath) || '',
scripts: ['vendor.bundle.js', 'app.bundle.js'].map(asset => {
const assetPath = absoluteMatch.test(asset) ? asset : `js/${asset}`
return {
path: assetPath,
hash: chunkMap[assetPath] || chunkMap[asset]
}
})
}
)
where somewhere before you do const project = config.get('project')
maybe though it's better to have it in an environment variable? |
When building a studio for use outside of development and
sanity.studio
-context, you might want not want to host it at the root of a domain name. In order to allow for this, we need to:/static
This PR implements the above, and also (for consistency) makes the development server use the same base path. I felt this would make it easier to debug routing issues, among other things.
Using it is as simple as adding a
basePath
property under theproject
object insanity.json
:When you access
/
in a development environment and a base path is set, we need to redirect to the correct location. This is currently handled inside of@sanity/default-layout
since it contains the root router, but we could consider moving this to theSanityRoot
component in@sanity/base
in order to ensure this is "always" applied regardless of layout. Thoughts?Fixes #692