VuePress is a minimalistic Vue.js-based documentation generator with component layout system and extensive plugin architecture.
—
The App class provides comprehensive site orchestration, configuration management, and build coordination for VuePress applications.
Central orchestrator for VuePress applications that manages configuration, plugins, pages, and build processes.
/**
* VuePress application instance
*/
class App {
/**
* Create a new VuePress application
* @param options - Application configuration options
*/
constructor(options?: AppOptions);
/** Application properties */
readonly isProd: boolean;
readonly options: AppOptions;
readonly sourceDir: string;
readonly vuepressDir: string;
readonly libDir: string;
readonly cwd: string;
readonly siteConfig: SiteConfig;
readonly base: string;
readonly themeConfig: any;
readonly tempPath: string;
readonly outDir: string;
readonly pages: Page[];
readonly pluginAPI: PluginAPI;
readonly markdown: any;
}Usage Examples:
const { createApp } = require("vuepress");
const app = createApp({
sourceDir: "./docs",
plugins: [["@vuepress/plugin-blog"]],
});
// Access app properties
console.log(app.sourceDir); // "./docs"
console.log(app.isProd); // false (in development)
console.log(app.pages.length); // Number of discovered pagesProcesses the application configuration, loads plugins, discovers pages, and prepares for build or development.
/**
* Process configuration, plugins, and prepare for build/dev
* This method must be called before dev() or build()
* @returns Promise that resolves when processing is complete
*/
async process(): Promise<void>;Usage Examples:
const app = createApp({
sourceDir: "./docs",
plugins: [
["@vuepress/plugin-last-updated"],
["@vuepress/plugin-register-components"],
],
});
// Process the app before using
await app.process();
// Now app.pages is populated with discovered pages
console.log(`Found ${app.pages.length} pages`);
app.pages.forEach(page => {
console.log(`Page: ${page.path} - ${page.title}`);
});Launches a development server with hot module replacement for real-time editing.
/**
* Launch development server with hot module replacement
* @returns Promise resolving to the App instance
*/
async dev(): Promise<App>;Usage Examples:
const app = createApp({
sourceDir: "./docs",
theme: "@vuepress/theme-default",
});
await app.process();
// Start development server
const devApp = await app.dev();
// Server starts on http://localhost:8080 (or next available port)
// The app instance provides access to dev server info
console.log("Development server running");Builds the static site for production deployment.
/**
* Build static site for production
* @returns Promise resolving to the App instance
*/
async build(): Promise<App>;Usage Examples:
const app = createApp({
sourceDir: "./docs",
dest: "./dist",
siteConfig: {
title: "My Documentation",
base: "/docs/",
},
});
await app.process();
// Build for production
const builtApp = await app.build();
// Static files generated in ./dist directory
console.log(`Built ${app.pages.length} pages to ${app.outDir}`);Dynamically adds a page to the application during processing.
/**
* Add a page to the application
* @param options - Page configuration options
* @returns Promise that resolves when page is processed
*/
async addPage(options: PageOptions): Promise<void>;
interface PageOptions {
/** Absolute file path of source file */
filePath?: string;
/** Relative path from source directory */
relative?: string;
/** URL path for the page */
path?: string;
/** Page title */
title?: string;
/** Markdown content */
content?: string;
/** Frontmatter data */
frontmatter?: any;
/** Permalink pattern */
permalinkPattern?: string;
}Usage Examples:
// Add page from file
await app.addPage({
filePath: "/absolute/path/to/file.md",
relative: "guide/advanced.md",
});
// Add virtual page with content
await app.addPage({
path: "/api/",
title: "API Reference",
content: "# API Reference\n\nGenerated API documentation...",
frontmatter: {
layout: "ApiLayout",
sidebar: false,
},
});
// Add page with custom permalink
await app.addPage({
filePath: "/path/to/blog-post.md",
permalinkPattern: "/blog/:year/:month/:day/:slug.html",
});Gets the site metadata that will be delivered to the client-side application.
/**
* Get site data for client-side application
* @returns Site metadata object
*/
getSiteData(): SiteData;
interface SiteData {
/** Site title */
title: string;
/** Site description */
description: string;
/** Base URL path */
base: string;
/** HTML head tags */
headTags: HeadTag[];
/** Array of page metadata */
pages: PageData[];
/** Theme configuration */
themeConfig: any;
/** Locale configuration */
locales?: LocaleConfig;
}Usage Examples:
await app.process();
const siteData = app.getSiteData();
console.log(`Site: ${siteData.title}`);
console.log(`Description: ${siteData.description}`);
console.log(`Base URL: ${siteData.base}`);
console.log(`Pages: ${siteData.pages.length}`);
// Access page data
siteData.pages.forEach(page => {
console.log(`${page.path}: ${page.title}`);
});Gets the path to a file within the core library directory.
/**
* Get file path within core library
* @param relative - Relative path within lib directory
* @returns Absolute path to library file
*/
getLibFilePath(relative: string): string;Usage Examples:
// Get path to client components
const clientPath = app.getLibFilePath("client/components/Content.js");
// Get path to webpack config
const webpackPath = app.getLibFilePath("node/webpack/createBaseConfig.js");
// Get path to templates
const templatePath = app.getLibFilePath("client/index.dev.html");
console.log(clientPath); // /path/to/vuepress/lib/client/components/Content.jsinterface AppOptions {
/** Source directory containing markdown files */
sourceDir?: string;
/** Array of plugin configurations */
plugins?: PluginConfig[];
/** Theme name or configuration object */
theme?: string | ThemeConfig;
/** Temporary directory path */
temp?: string;
/** Output directory path for build */
dest?: string;
/** Site configuration object */
siteConfig?: SiteConfig;
}interface SiteConfig {
/** Site title */
title?: string;
/** Site description */
description?: string;
/** Base URL path */
base?: string;
/** HTML head tags */
head?: HeadTag[];
/** Theme configuration */
themeConfig?: any;
/** Markdown configuration */
markdown?: MarkdownConfig;
/** File patterns to include */
patterns?: string[];
/** Permalink pattern */
permalink?: string;
/** Locale configuration */
locales?: LocaleConfig;
/** Temporary directory */
temp?: string;
/** Output directory */
dest?: string;
}Install with Tessl CLI
npx tessl i tessl/npm-vuepress