PixelOven.Copy

Overview

Copy is a utility API that helps copy static assets from src directories into a distribution directory. This can be useful for when developing component libraries that depend on static components throughout the development life cycle.

By Pattern

ArgumentRequiredDefaultDescription
<source>YesN/ASource path directory to copy from
<dest>No./disb/libDestination path to copy to
<pattern>No./**/*.{ico,scss,svg}Matching pattern for source files

There are three arguments available for copy files. All paths and patterns are relative to where the command is invoked.

Usage

While source is a required field both dest and the given pattern are not. Source generally is a path but can also be one of a few keywords.

yarn run pixeloven copy <source> <dest[optional]> <pattern[optional]>

More information about these <source> keywords can be found in our Shortcuts section below.

When <source> is not one of the args from above, copy will attempt to copy all contents of the source path/file to the provided dest path/file.

yarn run pixeloven copy /work/dir/file.txt /dist/lib/custom/dir/file.txt

Optionally we can provide a pattern to match specific file types against when copying between two locations.

yarn run pixelove copy /work/dir /dist/lib **.tsx

A common pattern where this might be used is as a post command hook after a compilation step has completed.

"scripts": {
"compile": "pixeloven compile ts",
"postcompile": "pixeloven copy src dist/lib **.{scss,jpg}"
}

Shortcuts

Note: The shortcuts listed below are based on our own opinions for directory structure. They are provided as a convenience. |Argument|Description| |---|---| |ico| Copies .ico files | |scss| Copies .scss files | |svg| Copies .svg files | |assets| Functions as an alias for combing all of the above cmds. |

All files in all subdirectories relative to where the command is run that have the file extension matching that of the above keywords will be copied to a default ./disb/lib directory. If the source provided is of an existing directory or file path, copy will attempt to copy all contents of the provided source path to a default ./dist/lib

Usage

The general pattern for these shortcuts follows the below pattern.

yarn run pixeloven copy <source>

A more specific example for copying scss into our distribution directory might look like the following.

pixeloven copy scss

As with the more general version a common pattern is to use this as a post command hook.

"scripts": {
"compile": "pixeloven compile ts",
"postcompile": "pixeloven copy assets"
}
Last updated on by Brian Gebel