[SOLVED] [setupSFC] [question] [nuxt] Error with setupSFC in Nuxt 3 #429
-
nuxt.config.ts: import vueMacros from 'unplugin-vue-macros/vite'
import vue from '@vitejs/plugin-vue'
export default defineNuxtConfig({
vite: {
vue: {
script: {
defineModel: true,
propsDestructure: true,
},
},
plugins: [
vueMacros(),
vue({
include: [/\.vue$/, /\.setup\.[cm]?[jt]sx?$/],
// ⬆️ setupSFC pattern need to be added
}) as any,
],
},
modules: [
'@vue-macros/nuxt',
],
}) pages/index.setup.tsx: export default () => (
<div>
<h1>Hello World</h1>
</div>
) EnvironmentOS: Windows 11 Home 10.0.22621 Build 22621 |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 4 replies
-
Attempts to solve itUnsuccessful. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Sorry to bother you again. It's not working for me. Same error of the image I provided. Tried removing My nuxt.config.ts: modules: [
'@pinia/nuxt',
'nuxt-quasar-ui',
'@nuxtjs/i18n',
'@vue-macros/nuxt',
],
macros: {
setupSFC: true,
}, Also tried with: macros: {
setupSFC: {
include: [/\.vue$/, /\.setup\.[cm]?[jt]sx?$/],
}
}, And: import vueMacros from 'unplugin-vue-macros/vite'
import vue from '@vitejs/plugin-vue'
...
vite: {
vue: {
script: {
defineModel: true,
propsDestructure: true,
},
},
plugins: [
vueMacros(),
vue({
include: [/\.vue$/, /\.setup\.[cm]?[jt]sx?$/],
// ⬆️ setupSFC pattern need to be added
}),
] as any,
}, Also in the demo, there's no |
Beta Was this translation helpful? Give feedback.
-
Solved?(finally!?) It's actually working. But there's a problem with Nuxt and VueRouter, that doesn't allow .setup.tsx files to be in the same folder of the After an exhausting amount of experimenting multime possible solutions, researching, But now this creates a new question, any way of telling VueRouter to use the setupSFC TSX syntax in its pages? |
Beta Was this translation helpful? Give feedback.
-
UpdateYup, I'm afraid this is a bug. I'm going to move it to an Issue. |
Beta Was this translation helpful? Give feedback.
-
Update 2Yup. I removed Then I add back And yes, I have |
Beta Was this translation helpful? Give feedback.
-
I give up 😔My last attempt, getting rid of Nuxt module, and adding the Vite plugins instead: And: And: |
Beta Was this translation helpful? Give feedback.
-
Please try |
Beta Was this translation helpful? Give feedback.
Please try
@vue-macros/nuxt@1.6.0
. Thanks for your detailed feedback! ❤️https://stackblitz.com/edit/nuxt-starter-ugvg9h?file=pages%2Findex.setup.tsx