I'm trying to embed SwaggerUI into my vuepress site. I got this far
<template><div :id="id">swagger</div>
</template>
<script>
// import { SwaggerUIBundle, SwaggerUIStandalonePreset } from "swagger-ui-dist"
import SwaggerUI from "swagger-ui";
import x from '@/upload-api.yml'
export default {
props: {
src: String
},
data() {
return {
id: null,
spec: {}
};
},
mounted() {
this.id = `swagger${this._uid}`;
// over here, I want to use `this.src` to pull the data
console.log(x);
},
updated() {
if (this.id !== null) {
SwaggerUI({
domNode: this.$el,
// dom_id: `#${this.id}`,
spec: this.spec,
});
}
}
};
</script>
<style></style>
In my plugin I have:
const path = require('path');
module.exports = {
chainWebpack (config, isServer) {
config.module
.rule("compile")
.test(/\.ya?ml$/)
.type("json")
.use("yaml")
.loader("yaml-loader");
config.resolve.alias.set("@", path.resolve("."));
Here's some other things I tried
console.log(require(this.src));
which gets me
[Vue warn]: Error in mounted hook: "Error: Cannot find module '@/upload-api.yml'"
This works though
console.log(require("@/upload-api.yml"));