TypeScript Copy Non-TS Files

0.1.9 · active · verified Sun Apr 19

typescript-cp is a utility designed to seamlessly copy non-TypeScript asset files into a TypeScript project's `outDir` during the build or watch process. It currently stands at version 0.1.9, indicating it's still in active development with minor releases for features and bug fixes, rather than a strict major-version-based cadence. Its core functionality integrates directly with TypeScript's project structure, honoring `tsconfig.json` configurations, particularly the `exclude` array, to prevent copying files that TypeScript itself ignores. Key differentiators include its CLI-first approach, ability to watch files for changes alongside `tsc -w`, and support for loader rules to transform asset content before copying, providing a more integrated solution than generic file copy utilities for TypeScript-specific workflows.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates `typescript-cp` integration into `package.json` scripts for both build and watch modes, running alongside `tsc`.

{
  "name": "my-ts-project",
  "version": "1.0.0",
  "description": "A sample project using typescript-cp",
  "main": "dist/index.js",
  "scripts": {
    "clean": "rm -rf dist",
    "build:ts": "tsc",
    "build:assets": "tscp",
    "build": "npm run clean && npm run build:ts && npm run build:assets",
    "watch:ts": "tsc -w",
    "watch:assets": "tscp -w",
    "start:dev": "npm run clean && npm run watch:ts & npm run watch:assets"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "typescript": ">=4.2.3",
    "typescript-cp": "^0.1.9"
  },
  "private": true
}

// To run the build:
// npm run build

// To start the dev watcher:
// npm run start:dev

view raw JSON →