vuepress-plugin-sbaudio
Version:
A music player plugin for vuepress use aplayer and meting
31 lines (30 loc) • 1.26 kB
JavaScript
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;
// 修改 @vuepress/bundler-vite 的配置项
if (app.options.bundler.name === "@vuepress/bundler-vite") {
bundlerOptions.viteOptions ?? (bundlerOptions.viteOptions = {});
// @ts-ignore
(_a = bundlerOptions.viteOptions).include ?? (_a.include = []);
// @ts-ignore
bundlerOptions.viteOptions.include = [
// @ts-ignore
...bundlerOptions.viteOptions.include,
"aplayer/dist/APlayer.min.js"
];
}
},
};
};
export default MetingPlugins;