https://github.com/body-builder/typescript-cp
Copy non-typescript files to outDir
https://github.com/body-builder/typescript-cp
asset copy file fs ts typescript watch watcher watchfile
Last synced: 8 months ago
JSON representation
Copy non-typescript files to outDir
- Host: GitHub
- URL: https://github.com/body-builder/typescript-cp
- Owner: body-builder
- Created: 2021-03-26T09:56:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-20T08:08:16.000Z (almost 3 years ago)
- Last Synced: 2025-06-28T13:45:37.230Z (12 months ago)
- Topics: asset, copy, file, fs, ts, typescript, watch, watcher, watchfile
- Language: TypeScript
- Homepage:
- Size: 148 KB
- Stars: 58
- Watchers: 4
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Typescript-cp
[](http://badge.fury.io/js/typescript-cp)
[](https://david-dm.org/body-builder/typescript-cp)
[](https://david-dm.org/body-builder/typescript-cp?type=dev)
[](https://david-dm.org/body-builder/typescript-cp?type=peer)
Copy non-typescript files to outDir
## Installation
`$ npm install typescript-cp -D`
## CLI
```shell
# Copy
$ tscp
# Copy for TS project references
$ tscp -b
# Watcher
$ tscp -w
# Watcher for TS project references
$ tscp -b -w
# Custom compiler settings
$ tscp -p tsconfig.production.json
# Help
$ tscp -h
```
## Example
package.json
```json5
{
//...
"scripts": {
"start": "tsc -w & tscp -w",
"build": "tsc && tscp"
},
//...
}
```
# Configuration
.tscprc
```json5
{
"ignored_files": ['**/an_ignored_file.ext'], // files not to copy (defaults to `['node_modules']`)
"compiled_files": [], // files compiled by TS (these also get ignored) (defaults to `['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx']`)
"use_ts_exclude": true, // ignore files that are listed in the tsconfig `exclude` array (defaults to `true`)
}
```
# Loaders
You can attach basic loader rules to the files. Loaders accept the actual content of the given file as the first parameter, and must return the content of the output file.
.tscprc.js
```js
const path = require('path');
/**
* @type {import('typescript-cp/dist/types').Config}
*/
module.exports = {
rules: [
{
test: /\.(scss|sass)$/,
include: [
path.resolve('./file-to-include.css'),
],
exclude: (source_path) => {
return source_path.indexOf('file-to-include.sass') > -1;
},
use: [
{
loader: (content, meta) => {
// Do something with `content`
return content;
},
},
],
},
],
};
```
See `Config` and `Rule` types in `src/types.ts` for the complete reference.
## Contribution
`$ npm run build`
----
Sponsored by: [SRG Group Kft.](https://srg.hu?en)