unplugin / unplugin-vue-markdown

Compile Markdown to Vue component
MIT License
508 stars 27 forks source link

Cannot work with Nuxt #46

Closed typed-sigterm closed 5 months ago

typed-sigterm commented 5 months ago

Describe the bug

When using in Nuxt, it will complain:

[plugin:vite:import-analysis] Failed to parse source for import analysis because the content contains invalid JS syntax. You may need to install appropriate plugins to handle the .md file format, or if it's an asset, add "**/*.md" to `assetsInclude` in your configuration.

Reproduction

https://stackblitz.com/edit/nuxt-demo-0fc9b48

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (6) x64 AMD Ryzen 5 4500U with Radeon Graphics
    Memory: 2.50 GB / 7.23 GB
  Binaries:
    Node: 20.10.0 - C:\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Local\pnpm\yarn.CMD
    npm: 10.2.3 - C:\nodejs\npm.CMD
    pnpm: 8.15.3 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.65), ChromiumDev (123.0.2420.10)
    Internet Explorer: 11.0.22621.1

Used Package Manager

pnpm

Validations

stackblitz[bot] commented 5 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

typed-sigterm commented 5 months ago

My problem.

The correct way is:

// nuxt.config.ts

 import Markdown from 'unplugin-vue-markdown/vite'

 export default defineNuxtConfig({
   vite: {
     plugins: [
       Markdown({}),
     ],
+    vue: {
+      include: [/\.vue$/, /\.md$/],
+    },
   },
-  vue: {
-    include: [/\.vue$/, /\.md$/],
-  },
 })