surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4k stars 779 forks source link

Nuxt Build Error #8376

Closed charlimxm closed 1 day ago

charlimxm commented 1 week ago

Hello! Am trying to use survey-vue3-ui library with Nuxt 3 app. Works in dev but error occurs when I try to build app for production

/plugins/survey.js

import { defineNuxtPlugin } from '#app'
import { surveyPlugin } from 'survey-vue3-ui';

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(surveyPlugin)
})

App works on nuxt dev.

Error occurs when I run nuxt build. Screenshot 2024-06-06 at 6 14 18 PM

How should I use the survey library with nuxt 3?

Specify your

JaneSjs commented 1 week ago

Hello @charlimxm, Thank you for sharing this code. Please ensure that your Nuxt configuration includes the plugin and CSS

nuxt.config.ts

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  devtools: { enabled: true },
  css: ['survey-core/defaultV2.min.css'],
  plugins: ['~/plugins/survey-plugin.ts'],
});

I created the following demo for your reference:

I confirm that the SurveyJS form appears correctly. image

Also, ran this demo locally and confirmed that the nuxt dev and nuxt build commands completes successfully. Here is the nuxt build commant output. image

Please let me know if this information helps.