dewfall123 / vitepress-for-component

📖 针对组件开发的VitePress。 重构版本https://github.com/dewfall123/ruabick
https://dewfall123.github.io/vitepress-for-component/
MIT License
193 stars 38 forks source link

vue 自定义指令,如何在vitepress 友好使用? #14

Closed bhabgs closed 3 years ago

bhabgs commented 3 years ago

vitepress 里使用 vue的自定义指令后,会提示相关错误。 image

custom directive is missing corresponding SSR transform and will be ignored.

dewfall123 commented 3 years ago

参考这个 https://github.com/vuejs/vue-next/issues/3298#issuecomment-785687683

传入ssr 自定义指令配置试下

// docs\.vitepress\config.js

vueOptions: {
    template: {
      ssr: true,
      compilerOptions: {
        directiveTransforms: {
          test: () => {
            return {
              props: [],
              needRuntime: true,
            };
          },
        },
      },
    },
  },
bhabgs commented 3 years ago

感谢您的分享,不知道您的解决方案是否能生效,我通过查看issuse 找到了 vitepress 相关布丁。 https://github.com/antfu/vite-ssg/issues/29