npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@talixo-ds/vite-plugin-copy-files

v2.0.2

Published

Vite plugin for copying build artifacts to external directories

Readme

@talixo-ds/vite-plugin-copy-files

A Vite plugin for copying build artifacts to external directories. Perfect for monorepo setups where you need to copy frontend build outputs to backend static directories (like Django static files).

Installation

npm install --save-dev @talixo-ds/vite-plugin-copy-files

Usage

Basic Setup

// vite.config.ts
import { defineConfig } from "vite";
import { copyFilesPlugin } from "@talixo-ds/vite-plugin-copy-files";

export default defineConfig({
	plugins: [
		copyFilesPlugin({
			destination: "../backend/static/frontend"
		})
	]
});

Environment Variable Configuration

The plugin supports the COPY_FILES_PATH environment variable, which takes precedence over the destination option:

# Set destination via environment variable
COPY_FILES_PATH=../backend/static/frontend npm run build
// vite.config.ts - destination will be overridden by env var
import { defineConfig } from "vite";
import { copyFilesPlugin } from "@talixo-ds/vite-plugin-copy-files";

export default defineConfig({
	plugins: [
		copyFilesPlugin() // Will use COPY_FILES_PATH env var
	]
});

Advanced Configuration

import { defineConfig } from "vite";
import { copyFilesPlugin } from "@talixo-ds/vite-plugin-copy-files";

export default defineConfig({
	plugins: [
		copyFilesPlugin({
			source: "dist", // Source directory (default: 'dist')
			destination: "../backend/static/frontend", // Destination directory
			cleanDestination: true, // Clean destination before copying (default: true)
			failOnError: true, // Fail build on copy errors (default: true)
			verbose: true, // Enable verbose logging (default: false)
			envVariableName: "STATIC_FILES_PATH", // Custom env var name (default: 'COPY_FILES_PATH')
			createDestination: true // Create destination if it doesn't exist (default: true)
		})
	]
});

API Reference

Plugin Options

interface CopyFilesOptions {
	/**
	 * Source directory to copy from
	 * @default 'dist'
	 */
	source?: string;

	/**
	 * Destination directory to copy to
	 * Can be overridden by environment variable
	 */
	destination?: string;

	/**
	 * Whether to clean the destination directory before copying
	 * @default true
	 */
	cleanDestination?: boolean;

	/**
	 * Whether to fail the build on copy errors
	 * @default true
	 */
	failOnError?: boolean;

	/**
	 * Enable verbose logging
	 * @default false
	 */
	verbose?: boolean;

	/**
	 * Custom environment variable name for destination path
	 * @default 'COPY_FILES_PATH'
	 */
	envVariableName?: string;

	/**
	 * Whether to create destination directory if it doesn't exist
	 * @default true
	 */
	createDestination?: boolean;
}

Functions

copyFilesPlugin(options?: CopyFilesOptions): Plugin

Creates the Vite plugin instance.

copyFiles(options: CopyFilesOptions, projectRoot: string): Promise<CopyResult>

Programmatically copy files (useful for testing or standalone usage).

Use Cases

Monorepo with Django Backend

// Frontend app vite.config.ts
export default defineConfig({
	plugins: [
		copyFilesPlugin({
			destination: "../../backend/myapp/static/frontend",
			verbose: true
		})
	]
});

Multiple Environments

# Development
COPY_FILES_PATH=../backend/static/dev npm run build

# Production
COPY_FILES_PATH=/var/www/static npm run build

CI/CD Pipeline

# .github/workflows/build.yml
- name: Build Frontend
  run: npm run build
  env:
   COPY_FILES_PATH: ./deployment/static

Error Handling

The plugin validates paths and provides clear error messages:

  • Source directory doesn't exist: Build fails with descriptive error
  • Destination not writable: Build fails with permission error
  • No destination specified: Build fails asking for destination config

You can control error behavior with the failOnError option:

copyFilesPlugin({
	failOnError: false // Logs warnings instead of failing build
});

Development

Building

npm run build

Testing

npm test

Running Tests in Watch Mode

npm run test

License

MIT