UNPKG

vuepress-plugin-sbaudio

Version:

A music player plugin for vuepress use aplayer and meting

34 lines (33 loc) 1.47 kB
import { getDirname, path } from "vuepress/utils"; import { deepmerge } from "deepmerge-ts"; import { MetingPluginsOptionsDefault } from "./options.js"; const __dirname = getDirname(import.meta.url); const MetingPlugins = (options = {}) => { options = deepmerge(MetingPluginsOptionsDefault, options); return { name: "vuepress-plugin-meting", async onPrepared(app) { await app.writeTemp("SbAudioOptions.json", JSON.stringify(options)); }, clientConfigFile: path.resolve(__dirname, "client.js"), extendsBundlerOptions: (bundlerOptions, app) => { var _a, _b; // 修改 @vuepress/bundler-vite 的配置项 if (app.options.bundler.name === "@vuepress/bundler-vite") { bundlerOptions.viteOptions ?? (bundlerOptions.viteOptions = {}); // @ts-ignore (_a = bundlerOptions.viteOptions).optimizeDeps ?? (_a.optimizeDeps = {}); // @ts-ignore (_b = bundlerOptions.viteOptions.optimizeDeps).include ?? (_b.include = []); // @ts-ignore bundlerOptions.viteOptions.optimizeDeps.include = [ // @ts-ignore ...bundlerOptions.viteOptions.optimizeDeps.include, "aplayer/dist/APlayer.min.js", "hls.js/dist/hls.min.js", ]; } }, }; }; export default MetingPlugins;