koumoul-dev / vuetify-jsonschema-form

Create beautiful and low-effort forms that output valid data. Published on npm as @koumoul/vjsf.
https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/
MIT License
538 stars 154 forks source link

Nuxt static generated site will not render form #305

Closed clwillingham closed 2 years ago

clwillingham commented 2 years ago

The Problem

After creating a nuxtjs project from scratch, configuring transpilation as recommended by vjsf docs and setting target to static and ssr to false and implementing a basic vjsf example, vjsf only renders the form in dev mode. after running npm generate and serving the static content with npm start, vjsf does not display.

example

source: https://github.com/clwillingham/nuxt-vjsf-test hosted example: https://hospitable-grain.surge.sh/

How to replicate

  1. clone example project
  2. run npm run dev to verify vjsf is functioning as expected
  3. run npm run generate
  4. run npm run start to host static content locally and see that vjsf is not rendering form as expected
albanm commented 2 years ago

The transpile option is only to be used if you import the library from source instead of dist. So you need this:

import VJsf from '@koumoul/vjsf/lib/VJsf.js'
import '@koumoul/vjsf/lib/VJsf.css'

Instead of this:

import VJsf from '@koumoul/vjsf'
import '@koumoul/vjsf/dist/main.css'
clwillingham commented 2 years ago

That addresses the issue. Thank you! Also thank you for developing and maintaining VJSF

dawadam commented 1 year ago

Please add to the documentation.

albanm commented 1 year ago

Well it is in the documentation https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/getting-started

Using transpile option is described in the section "Import module from source" not in the section "Import built version of the module".