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

static file not being served in build #17

Closed
bwgjoseph opened this issue Feb 17, 2023 · 3 comments
Closed

static file not being served in build #17

bwgjoseph opened this issue Feb 17, 2023 · 3 comments

Comments

@bwgjoseph
Copy link

I created a page to display all my json-schema (i,e /schema), I used schema.mdx file to display it

image

In each of the mdx file, it looks something like this but importing different json file

import JSONSchemaViewer from "@theme/JSONSchemaViewer"
import schema from "@site/static/schema/geo.json"

<JSONSchemaViewer schema={schema} />

In local development, it works as expected.

image

But when I build and serve it, it doesn't load the content

image

Not sure if it matters but I'm using javascript setup of docusaurus instead of typescript.

Let me know if more information is required, or if this is a docusaurus issue, then I can redirect over to their repo.

Thanks!

@jy95
Copy link
Owner

jy95 commented Feb 17, 2023

Hello @bwgjoseph

It is indeed weird it doesn't work for javascript as on my typescript documentation website, it works.
( mdx example & example page )

As Docusaurus own website uses resolveJsonModule setting like mime, I think you can ask them their feedback.
You can read https://docusaurus.io/docs/static-assets in the meantime and see if there is differences between require / import:

// import way
import schema from "@site/static/schema/geo.json"
// require way
require('@site/static/schema/geo.json').default}

Worthy to mention, release 1.2.0 is on the road - I can notify you when it is ready ;)

@bwgjoseph
Copy link
Author

Usually on first visit after a build will get this

image

I did read that, and tried require before I reported

import JSONSchemaViewer from "@theme/JSONSchemaViewer"
var schema = require('@site/static/schema/geo.json')

<JSONSchemaViewer schema={schema} />

And I just tried

import JSONSchemaViewer from "@theme/JSONSchemaViewer"
const schema = require('@site/static/schema/geo.json').default

<JSONSchemaViewer schema={schema} />

Both way does not work too. Still getting the loading... screen

Worthy to mention, release 1.2.0 is on the road - I can notify you when it is ready ;)

Sure! Thanks for creating this plugin.

@bwgjoseph
Copy link
Author

hey, I managed to solve it (see facebook/docusaurus#8676 (comment)) (i think)

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