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

Build failed with Link Preview Plugin #251

Open
Kutius opened this issue Jul 11, 2024 · 4 comments
Open

Build failed with Link Preview Plugin #251

Kutius opened this issue Jul 11, 2024 · 4 comments
Labels
bug Something isn't working difficulty/hard Hard to deal with / implement against documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed pkg/inline-link-preview Related to @nolebase/vitepress-plugin-inline-link-preview

Comments

@Kutius
Copy link

Kutius commented Jul 11, 2024

config:

// defineconfig...
  markdown: {
    config: (md) => {
      md.use(InlineLinkPreviewElementTransform)
    },
    theme: {
      light: 'light-plus',
      dark: 'dark-plus',
    },
    codeTransformers: [
      transformerTwoslash(),
    ],
  },

// theme/index.ts
  enhanceApp({ app, router, siteData }) {
    app.use(TwoslashFloatingVue)
    app.use(NolebaseGitChangelogPlugin)
    app.use(NolebaseInlineLinkPreviewPlugin)
    app.provide(InjectionKey, {
      spotlight: {
        defaultToggle: true,
      },
    })
    // ...
  },

output:

Unknown file extension ".vue" for /home/i/wiki/node_modules/@nolebase/vitepress-plugin-inline-link-preview/dist/client/components/InlineLinkPreview.vue
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".vue" for /home/i/wiki/node_modules/@nolebase/vitepress-plugin-inline-link-preview/dist/client/components/InlineLinkPreview.vue
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async ModuleLoader.load (node:internal/modules/esm/loader:396:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:45)
error: script "docs:build" exited with code 1

It looks like an SSG configuration error.

@nekomeowww
Copy link
Member

Do you have a minimal reproduction that I can dig into?

What was your Vite config, VitePress config and theme config?

@Kutius
Copy link
Author

Kutius commented Jul 11, 2024

@nekomeowww Maybe I found the key

This is Vite config:

  vite: {
    plugins: [
      Unocss(),
      GitChangelog({
        // 填写在此处填写您的仓库链接
        repoURL: () => 'https://xxx.com/knowledge/wiki/tree/@next-vitepress',
        getCommitURL: commit => `${commit.repo_url?.replace('/tree/@next-vitepress', '')}/commit/${commit.hash}`,
      }),
      GitChangelogMarkdownSection(),
    ],
    optimizeDeps: {
      exclude: [
        '@nolebase/vitepress-plugin-enhanced-readabilities/client',
      ],
    },
    ssr: {
      noExternal: [
        // 如果还有别的依赖需要添加的话,并排填写和配置到这里即可
        '@nolebase/vitepress-plugin-enhanced-readabilities',
      ],
    },
  },

When I replace the value in ssr noEXternal

'@nolebase/vitepress-plugin-enhanced-readabilities'

to

'@nolebase/*'

And then get no error

@nekomeowww nekomeowww added bug Something isn't working pkg/inline-link-preview Related to @nolebase/vitepress-plugin-inline-link-preview difficulty/hard Hard to deal with / implement against labels Jul 12, 2024
@cosmic-jellyfish
Copy link

Just chiming in here, doing the solution mentioned above works.

Original error:

vitepress v1.3.0

✓ building client + server bundles...
build error:
Unknown file extension ".vue" for E:\Users\cake\Desktop\Test\node_modules\@nolebase\vitepress-plugin-inline-link-preview\dist\client\components\PopupIframe.vue
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".vue" for E:\Users\cake\Desktop\Test\node_modules\@nolebase\vitepress-plugin-inline-link-preview\dist\client\components\PopupIframe.vue
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async ModuleLoader.load (node:internal/modules/esm/loader:396:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:45)

Was the error given

However using this config:

   vite: {
    optimizeDeps: {
      exclude: [
        '@nolebase/vitepress-plugin-inline-link-preview/markdown-it',
      ],
    },
    ssr: {
      noExternal: [
        '@nolebase/*',
      ],
    },
  },

has made it work.

I originally had either no config placed (testing purposes) or with @nolebase/vitepress-plugin-inline-link-preview/markdown-it placed in the ssr caused the error.

@nekomeowww
Copy link
Member

Sorry for the delay, I was in Hackathon last week and we had no time to focus on Nolebase communities. Apologize for the delay, really!

Please, much appriciated if any of you would like to take a look into this, a documentation contribution to mention this out is welcome too!

@nekomeowww nekomeowww added documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed labels Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working difficulty/hard Hard to deal with / implement against documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed pkg/inline-link-preview Related to @nolebase/vitepress-plugin-inline-link-preview
Projects
None yet
Development

No branches or pull requests

3 participants