### Migrating Existing Workflows to setup-vp Source: https://viteplus.dev/guide/ci This example shows how to simplify an existing GitHub Actions workflow by replacing multiple Node.js and package manager setup steps with a single `setup-vp` action. ```yaml - uses: pnpm/action-setup@v6 with: version: 11 - uses: actions/setup-node@v6 with: node-version: '24' cache: pnpm - run: pnpm ci && pnpm dev:setup - run: pnpm check - run: pnpm test ``` ```yaml - uses: voidzero-dev/setup-vp@v1 with: node-version: '24' cache: true - run: vp install && vp run dev:setup - run: vp check - run: vp test ``` -------------------------------- ### Vite+ Quick Start Commands Source: https://viteplus.dev/guide Use these commands to quickly create, install dependencies, develop, check, test, and build your Vite+ project. ```bash vp create # Create a new project vp install # Install dependencies vp dev # Start the dev server vp check # Format, lint, type-check vp test # Run JavaScript tests vp build # Build for production ``` -------------------------------- ### Install Global `vp` Preview (Bash) Source: https://viteplus.dev/guide/upgrade Install a preview build of the global Vite+ CLI by passing a pull request number or commit SHA to the installer script. This command fetches the specified preview build through the registry bridge. ```bash curl -fsSL https://vite.plus | VP_PR_VERSION= bash ``` -------------------------------- ### Install Global `vp` Preview (PowerShell) Source: https://viteplus.dev/guide/upgrade Install a preview build of the global Vite+ CLI on Windows using PowerShell. Set the VP_PR_VERSION environment variable with a pull request number or commit SHA before running the installer script. ```powershell $env:VP_PR_VERSION = "" irm https://vite.plus/ps1 | iex Remove-Item Env:\VP_PR_VERSION ``` -------------------------------- ### GitHub Actions CI Setup with setup-vp Source: https://viteplus.dev/guide/ci Use this snippet to set up Vite+ in your GitHub Actions workflow. It installs the specified Node.js version, enables dependency caching, and runs standard Vite+ commands. ```yaml - uses: voidzero-dev/setup-vp@v1 with: node-version: '24' cache: true - run: vp install - run: vp check - run: vp test - run: vp build ``` -------------------------------- ### Install and Configure Commit Hooks Source: https://viteplus.dev/guide/commit-hooks Use `vp config` to set up project hooks and related integrations. Use `--hooks-dir` to specify a custom directory for hooks. Use `--no-hooks` to leave existing Git hook setup unchanged. Use `--no-agent` to skip updates to coding agent instruction files. ```bash vp config vp config --hooks-dir .vite-hooks vp config --no-hooks vp config --no-agent ``` -------------------------------- ### Vite+ Installation for Workspace Source: https://viteplus.dev/guide/install An alternative shorthand for filtering installation to a specific workspace. ```bash vp install -w ``` -------------------------------- ### vpx Examples Source: https://viteplus.dev/guide/vpx Demonstrates various ways to use `vpx` to run different tools and packages with arguments. ```bash vpx eslint . ``` ```bash vpx create-vue my-app ``` ```bash vpx typescript@5.5.4 tsc --version ``` ```bash vpx -p cowsay -c 'echo "hi" | cowsay' ``` -------------------------------- ### vp exec Examples Source: https://viteplus.dev/guide/vpx Shows how to run project-local binaries like `eslint` and `tsc` using `vp exec`. ```bash vp exec eslint . ``` ```bash vp exec tsc --noEmit ``` -------------------------------- ### Basic Vite+ Installation Source: https://viteplus.dev/guide/install Run this command to install project dependencies using Vite+'s underlying package manager. ```bash vp install ``` -------------------------------- ### vp dlx Examples Source: https://viteplus.dev/guide/vpx Illustrates using `vp dlx` to run package binaries like `create-vite` and `typescript` without adding them to dependencies. ```bash vp dlx create-vite ``` ```bash vp dlx typescript tsc --version ``` -------------------------------- ### Verify Vite+ Installation Source: https://viteplus.dev/guide After installation, run this command in a new shell to verify that Vite+ is installed correctly and to view its help information. ```bash vp help ``` -------------------------------- ### Start Vite Development Server Source: https://viteplus.dev/guide/dev Use this command to launch the Vite development server. It provides the standard Vite development experience. ```bash vp dev ``` -------------------------------- ### Global Package Installation with Vite+ Source: https://viteplus.dev/guide/install Installs a package globally using Vite+'s custom global package management system, which is separate from the Node.js global installation. ```bash vp install -g ``` -------------------------------- ### Vite+ Create Command Examples Source: https://viteplus.dev/guide/create Demonstrates various ways to use the 'vp create' command, including interactive mode, scaffolding different project types, using shorthand and full package names for templates, and utilizing remote templates from GitHub or URLs. ```bash # Interactive mode vp create ``` ```bash # Create a Vite+ monorepo, application, library, or generator vp create vite:monorepo vp create vite:application vp create vite:library vp create vite:generator ``` ```bash # Use shorthand community templates vp create vite vp create @tanstack/start vp create svelte ``` ```bash # Use full package names vp create create-vite vp create create-next-app ``` ```bash # Use remote templates vp create github:user/repo vp create https://github.com/user/template-repo ``` -------------------------------- ### Install Vite+ on Windows Source: https://viteplus.dev/guide Use this PowerShell command to download and execute the Vite+ installation script on Windows systems. ```powershell irm https://vite.plus/ps1 | iex ``` -------------------------------- ### Install Project Dependencies Source: https://viteplus.dev/guide/install Installs dependencies based on the current package.json and lockfile. Use --frozen-lockfile to prevent lockfile changes. ```bash vp install ``` ```bash vp install --frozen-lockfile ``` ```bash vp install --no-frozen-lockfile ``` ```bash vp install --lockfile-only ``` ```bash vp install --prefer-offline ``` ```bash vp install --offline ``` ```bash vp install --ignore-scripts ``` ```bash vp install --filter ``` ```bash vp install -w ``` -------------------------------- ### Vite+ Environment Setup Commands Source: https://viteplus.dev/guide/env Commands to set up and configure the Vite+ environment for Node.js management. ```bash # Setup vp env setup # Create shims for node, npm, npx, corepack vp env on # Use Vite+ managed Node.js vp env print # Print shell snippet for this session ``` ```bash # Manage vp env pin lts # Pin the project to the latest LTS release vp env install # Install the version from .node-version or package.json vp env default lts # Set the global default version vp env use 20 # Use Node.js 20 for the current shell session vp env use --unset # Remove the session override ``` ```bash # Inspect vp env current # Show current resolved environment vp env current --json # JSON output for automation vp env which node # Show which node binary will be used vp env which npx # Show pinned package-manager alias when packageManager matches vp env list-remote --lts # List only LTS versions ``` ```bash # Execute vp env exec --node lts npm i # Execute npm with latest LTS vp env exec node -v # Use shim mode with automatic version resolution vp node script.js # Shorthand: run a Node.js script with the resolved version vp node -e "console.log(1+1)" # Shorthand: forward any node flag or argument ``` -------------------------------- ### Install Vite+ on macOS/Linux Source: https://viteplus.dev/guide Use this command to download and execute the Vite+ installation script on macOS and Linux systems. ```bash curl -fsSL https://vite.plus | bash ``` -------------------------------- ### Inspect Dependencies Source: https://viteplus.dev/guide/install Provides information about installed packages, their reasons for being present, and registry metadata. ```bash vp list ``` ```bash vp why react ``` ```bash vp info react ``` -------------------------------- ### Install Node.js from Custom Mirror Source: https://viteplus.dev/guide/env Use this command to install a specific Node.js version from a custom mirror. Ensure the VP_NODE_DIST_MIRROR environment variable is set to your mirror's URL. ```bash VP_NODE_DIST_MIRROR=https://my-mirror.example.com/nodejs/dist vp env install 22 ``` -------------------------------- ### Package.json Scripts for Cache Sharing Source: https://viteplus.dev/guide/cache Example package.json scripts demonstrating how common tasks can share cache entries if caching is enabled. ```json { "scripts": { "check": "vp lint && vp build", "release": "vp lint && deploy-script" } } ``` -------------------------------- ### Vite+ Installation with Lockfile Only Source: https://viteplus.dev/guide/install This command installs dependencies strictly based on the existing lockfile, without updating it. ```bash vp install --lockfile-only ``` -------------------------------- ### Vite+ Installation with Frozen Lockfile Source: https://viteplus.dev/guide/install Use this option to ensure that the lockfile is not modified during installation, guaranteeing reproducible builds. ```bash vp install --frozen-lockfile ``` -------------------------------- ### Full Migration with Local `vite-plus` Source: https://viteplus.dev/guide/upgrade To perform a full migration that includes first-time setup steps like git hooks and editor files, pass the `--full` flag to `vp migrate`. ```bash vp migrate --full ``` -------------------------------- ### Run Binary with vp dlx Source: https://viteplus.dev/guide/vpx Execute a package binary for one-off use without installing it as a project dependency. Ideal for temporary or infrequent tools. ```bash vp dlx [args...] ``` -------------------------------- ### Example Cache Key Configuration Source: https://viteplus.dev/guide/github-actions-cache Configure a rolling primary key with a restore prefix for effective cache management. Include runner OS and architecture, and per-run identifiers like run_id and run_attempt. Track dependency files in the task fingerprint, not the Actions key. ```yaml key: vite-task-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | vite-task-${{ runner.os }}-${{ runner.arch }}- ``` -------------------------------- ### Cache Miss Examples Source: https://viteplus.dev/guide/cache Examples of cache miss messages indicating why a task is being re-executed. ```bash $ vp lint ✗ cache miss: 'src/utils.ts' modified, executing ``` ```bash $ vp build ✗ cache miss: env 'VITE_GREETING' changed, executing ``` ```bash $ vp test ✗ cache miss: args changed, executing ``` -------------------------------- ### Enable Managed Mode with vp env Source: https://viteplus.dev/guide/env Run this command to enable managed mode, ensuring shims always use the Vite+-managed Node.js installation. ```bash vp env on ``` -------------------------------- ### Vite+ Installation Filtered by Workspace Source: https://viteplus.dev/guide/install Install dependencies for a specific workspace within your project using the --filter flag. ```bash vp install --filter web ``` -------------------------------- ### Run Package Binary Source: https://viteplus.dev/guide/install Executes a package's binary without installing it as a project dependency. ```bash vp dlx create-vite ``` -------------------------------- ### Install libstdc++ on Alpine Linux Source: https://viteplus.dev/guide On Alpine Linux systems using musl, install the libstdc++ package before using Vite+ to ensure compatibility with the managed Node.js runtime. ```sh apk add libstdc++ ``` -------------------------------- ### Upgrade Global `vp` Command Source: https://viteplus.dev/guide/upgrade Use these commands to manage the global `vp` binary. You can upgrade to the latest version, check for updates, install a specific version, or use a custom npm registry. ```bash vp upgrade # upgrade to the latest version vp upgrade --check # check for updates without installing vp upgrade # install a specific version vp upgrade --registry # use a custom npm registry ``` -------------------------------- ### Ad-hoc Command Execution Source: https://viteplus.dev/guide/docker Run any `vp` command against your project without installing `vp` locally. This command mounts your current directory into the container and executes the specified `vp` command. ```bash docker run --rm -it -v "$PWD:/app" -w /app ghcr.io/voidzero-dev/vite-plus:latest vp build ``` -------------------------------- ### Vite+ Pack Configuration for Standalone Executables Source: https://viteplus.dev/guide/pack Configure `vp pack` to build standalone executables by setting the `entry` point and enabling the `exe` option. This is useful for shipping CLI tools that do not require a separate Node.js installation. ```typescript import { defineConfig } from 'vite-plus'; export default defineConfig({ pack: { entry: ['src/cli.ts'], exe: true, }, }); ``` -------------------------------- ### Composing Lint Configuration for Node.js Source: https://viteplus.dev/guide/monorepo Define reusable linting configurations for specific frameworks or environments. This example shows a Node.js-specific lint configuration. ```typescript import type { OxlintOverride } from 'vite-plus/lint'; export const nodeLint = { env: { node: true, }, rules: { 'no-console': 'off', }, } satisfies Omit; ``` -------------------------------- ### Vite+ Pack Configuration for Libraries Source: https://viteplus.dev/guide/pack Configure packaging options directly in the `pack` block of `vite.config.ts`. This example enables declaration file generation, specifies multiple output formats (ESM and CJS), and enables source maps. ```typescript import { defineConfig } from 'vite-plus'; export default defineConfig({ pack: { dts: true, format: ['esm', 'cjs'], sourcemap: true, }, }); ``` -------------------------------- ### CI Pipeline Configuration Source: https://viteplus.dev/guide/docker Integrate the Vite Plus Docker image into your CI pipeline to automate build and test processes. This example shows a basic GitLab CI configuration. ```yaml build: image: ghcr.io/voidzero-dev/vite-plus:latest script: - vp install --frozen-lockfile - vp check - vp test - vp build ``` -------------------------------- ### Build Static SPA/SSG with Dockerfile Source: https://viteplus.dev/guide/docker Use this Dockerfile to build a static Single Page Application (SPA) or Static Site Generator (SSG) project. It leverages a multi-stage build to first install dependencies and build the project, then copies the output to an Nginx server for serving. ```docker FROM ghcr.io/voidzero-dev/vite-plus:latest AS build WORKDIR /app COPY --chown=vp:vp package.json pnpm-lock.yaml .node-version* ./ RUN vp install --frozen-lockfile COPY --chown=vp:vp . . RUN vp build FROM nginx:alpine AS runtime COPY --from=build /app/dist /usr/share/nginx/html ``` -------------------------------- ### List Available Templates Source: https://viteplus.dev/guide/create Run this command to display a list of all available built-in and popular shorthand templates that `vp create` recognizes. ```bash vp create --list ``` -------------------------------- ### Serve Production Build Locally Source: https://viteplus.dev/guide/build After building your application with `vp build`, use `vp preview` to serve the generated production build locally for testing. ```bash vp build vp preview ``` -------------------------------- ### Basic `vp create` Usage Source: https://viteplus.dev/guide/create Use this command to interactively scaffold a new Vite+ project. It will prompt you for template selection and configuration. ```bash vp create ``` -------------------------------- ### Basic vp fmt Usage Source: https://viteplus.dev/guide/fmt Run `vp fmt` to format your project. Use `vp fmt --check` to check formatting without writing changes. Use `vp fmt . --write` to format the current directory and write changes. ```bash vp fmt ``` ```bash vp fmt --check ``` ```bash vp fmt . --write ``` -------------------------------- ### Create Project with Template Options Source: https://viteplus.dev/guide/create Pass options directly to the template using the `--` separator. This allows for fine-grained control over template-specific configurations. ```bash vp create