forked from vue-styleguidist/vuepress-plugin-live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenhanceAppFiles.js
22 lines (21 loc) · 975 Bytes
/
enhanceAppFiles.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const path = require("path");
const vueLivePath = path.join(__dirname, "./vueLiveWithLayout");
module.exports = function enhanceAppFiles() {
const content = [
// import live with es6 so that it is compatible with both build and dev
'import Vue from "vue";',
// vuepress is compiled in both node and non-node models
// it needs a "global" variable to make buble work.
// one of its dependencies, buffer uses global to detect compat with browser
// it is missing in browsers, so we add it.
'if (typeof window !== "undefined" && window.global === undefined) {',
" window.global = window;",
"}",
// and in order for the loading to happen after we assign the variable,
// we load vue-live as a require instead of an import
`Vue.component("VueLive", () => import(${JSON.stringify(
vueLivePath
)}));Vue.component("NoSsr", () => import('vue-no-ssr')) `
].join("\n");
return { name: "vue-live-enhancer", content };
};