From 2117297f7c3dab7a56ab3e8bc17004a8b77650ee Mon Sep 17 00:00:00 2001 From: hmol233 <82594500+hmol233@users.noreply.github.com> Date: Mon, 3 May 2021 12:57:54 +0800 Subject: [PATCH] Upgrade vuepress to beta.12 (#26) --- .prettierignore | 1 + docs/.vuepress/config.ts | 28 +- docs/.vuepress/theme/components/Tab.vue | 2 +- docs/.vuepress/theme/components/Tabs.vue | 11 +- .../theme/styles/default/_variables.scss | 7 +- .../.vuepress/theme/styles/default/index.scss | 21 + package.json | 11 +- yarn.lock | 485 +++++++++++------- 8 files changed, 364 insertions(+), 202 deletions(-) diff --git a/.prettierignore b/.prettierignore index 7e5f626..17b1d76 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,5 @@ node_modules/ .vuepress/dist +.cache/ .temp/ dist/ diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index 6b7b2fd..a349ba9 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -1,12 +1,28 @@ -import { defineUserConfig, DefaultThemeOptions } from "vuepress"; +import { defineUserConfig } from "@vuepress/cli"; +import type { DefaultThemeOptions } from "@vuepress/theme-default"; import * as sidebar from "./config/sidebar"; import * as navbar from "./config/navbar"; import * as path from "path"; +const isProduction = process.env.NODE_ENV === "production"; + export default defineUserConfig({ theme: path.join(__dirname, "./theme"), - plugins: ["@vuepress/back-to-top", "vuepress-plugin-mermaidjs"], - base: "/Xray-docs-next/", + plugins: [ + ["vuepress-plugin-mermaidjs"], + [ + "@vuepress/plugin-search", + { + locales: { + "/": { + placeholder: "搜索", + }, + }, + }, + ], + ["@vuepress/plugin-debug", !isProduction], + ], + base: isProduction ? "/Xray-docs-next/" : "", locales: { "/": { lang: "zh-CN", @@ -24,7 +40,7 @@ export default defineUserConfig({ enableToggle: true, themePlugins: { - git: process.env.NODE_ENV === "production", + git: isProduction, }, locales: { "/": { @@ -71,6 +87,7 @@ export default defineUserConfig({ extendsMarkdown: (md) => { md.use(require("markdown-it-footnote")); }, + bundler: isProduction ? "@vuepress/webpack" : "@vuepress/vite", bundlerConfig: { chainWebpack: (config) => { config.module @@ -82,6 +99,9 @@ export default defineUserConfig({ name: `assets/img/[name].[hash:8].[ext]`, }); }, + viteOptions: { + base: "/Xray-docs-next/", + }, }, //postcss: { plugins: [require("autoprefixer")] } }); diff --git a/docs/.vuepress/theme/components/Tab.vue b/docs/.vuepress/theme/components/Tab.vue index 4a737fd..14755da 100644 --- a/docs/.vuepress/theme/components/Tab.vue +++ b/docs/.vuepress/theme/components/Tab.vue @@ -37,5 +37,5 @@ export default defineComponent({ diff --git a/docs/.vuepress/theme/components/Tabs.vue b/docs/.vuepress/theme/components/Tabs.vue index 4dec442..c077512 100644 --- a/docs/.vuepress/theme/components/Tabs.vue +++ b/docs/.vuepress/theme/components/Tabs.vue @@ -42,9 +42,12 @@ export default defineComponent({ }, mounted() { this.$nextTick(function () { - const bootstrap = require("bootstrap"); - let triggerEl = document.getElementById(this.children["0"].$data.labelID); - new bootstrap.Tab(triggerEl).show(); + import("bootstrap").then((b) => { + let triggerEl = document.getElementById( + this.children["0"].$data.labelID + ); + new b.Tab(triggerEl).show(); + }); }); }, computed: { @@ -59,7 +62,7 @@ export default defineComponent({