question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integration with vue and vitepress

See original GitHub issue

Hello mrin9,

I am playing with vitepress and trying to have rapidoc v9.3.3 embedded. It worked out great when running in dev mode with hot reloads, but when I tried to do a build, it gave:

build error:
 ReferenceError: self is not defined
    at /home/vitepress_test/node_modules/.pnpm/rapidoc@9.3.3/node_modules/rapidoc/dist/rapidoc-min.js:3788:57478
    at /home/vitepress_test/node_modules/.pnpm/rapidoc@9.3.3/node_modules/rapidoc/dist/rapidoc-min.js:3788:58207
    at Object.<anonymous> (/home/vitepress_test/node_modules/.pnpm/rapidoc@9.3.3/node_modules/rapidoc/dist/rapidoc-min.js:3788:58218)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29)
    at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
    at async Loader.import (internal/modules/esm/loader.js:178:24)
 ELIFECYCLE  Command failed with exit code 1.

I tried to search (and I am actually new to every aspects) on the net and nothing actually worked. I was wondering if there is any tips you can give? Thanks so much in advance.

Best regards,

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
neildchencommented, Sep 28, 2022

To whom it may concern, I just want to leave some notes if there is anyone when may have found helpful. Thanks to @bertrandk and @mrin9 tips, below are what I have done and using vitepress it now builds and works properly:

api_service.vue

<template>
    <!-- For render-style=read you should try to provide height of rapi-doc element as it needs to calculate scroll positions-->
    <rapi-doc
        ref="rapidoc"
        theme="light"
        allow-spec-url-load="false"
        allow-spec-file-load="true"
        show-header="false"
        show-info="true"
        font-size="largest"
        render-style="focused"
        allow-try="true"
        regular-font="Arial"
        mono-font="monospace"
        bg-color="#ffffff"
        nav-bg-color="#fafafa"
        nav-text-color="#a9b7d0"
        nav-hover-bg-color="#ffebea"
        nav-hover-text-color="#9b0700"
        nav-accent-color="#f87070"
        primary-color="#F63C41"
        show-method-in-nav-bar="as-colored-block"
        nav-item-spacing="relaxed"
        style="height:88vh; width:100%"
    ></rapi-doc>
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-facing-decorator";
// import "rapidoc";  // comment this line out

@Component({
    name: "rapidoc",
})

export default class ApiService extends Vue {
    mounted() {
        // do the import here
        import('rapidoc').then(() => {
            this.$nextTick(() => {
                // have the spec in json ready somewhere
                // in my case, it's under docs/.vitepress/dist/swagger_source
                this.$refs.rapidoc.loadSpec(`./swagger_source/api_service.json`);   
            })
        })
    }
}
</script>

<style scoped>
/* Overwrite CSS global vars to style web component */
rapi-doc {
    overflow-y: visible;
    overflow-x: hidden;
}
</style>

api_service.md

---
{
    title: "API Service",
    layout: page,
}
---

<script setup>
    import ApiService from "./api_service.vue";
</script>

<ClientOnly>
    <ApiService></ApiService>
</ClientOnly>

index.md

---
    layout: doc
---

# Documentations

## [API Service](./api_service.md)

if any one needs more detailed information, leave me a message and I will try to help as I can. Thanks.

0reactions
neildchencommented, Sep 28, 2022

@bertrandk thank you very much, I will study more on ClientOnly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Vue in Markdown - VitePress
In VitePress, each markdown file is compiled into HTML and then processed as a Vue Single-File Component. This means you can use any...
Read more >
Next steps for VitePress · Discussion #548 - GitHub
I have a feature request on integrating VitePress into an existing (Vue) Vite project with access to all its (generated) resources. I'm new...
Read more >
VitePress Tutorial With Vue.js 3: The New Vite Static ... - Morioh
Vitepress is the latest Static Site Generator based off of Vite + Vuepress. ... Due to its ease of integration, Vue.js is becoming...
Read more >
Vitepress - npm.io
vitepress. Vite & Vue powered static site generator ... SideBar Generator for vuepress-next and vitepress ... Vite specific framework integration helpers.
Read more >
Configuring TailwindCSS to work with Vitepress
1. Import TailwindCSS through their CDN: Edit your config file at .vitepress/config.js and add the following. js
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found