Webpack plugin to copy, archive (.zip), move, delete files and directories before and after builds
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Copy individual files or entire directories with glob pattern support, flexible destination handling, and comprehensive options for preserving metadata and controlling behavior.
Main copy action function that processes copy tasks.
/**
* Execute copy tasks with the provided options
* @param tasks Array of copy tasks to execute
* @param taskOptions Execution options including logger and error handling
*/
function copyAction(tasks: CopyTask[], taskOptions: TaskOptions): Promise<void>;
export default copyAction;Options for controlling copy behavior, file handling, and metadata preservation.
/**
* Options for copy operations extending fs-extra CopyOptions
*/
interface CopyActionOptions extends FsCopyOptions {
/** Flatten directory structure - copy all files to destination root (default: false) */
flat?: boolean;
}
/**
* fs-extra copy options used by CopyActionOptions
*/
type FsCopyOptions = Pick<CopyOptions, 'overwrite' | 'preserveTimestamps'>;
/**
* Fast-glob options for copy operations (excludes absolute and cwd)
*/
type CopyGlobOptions = Omit<FgOptions, 'absolute' | 'cwd'>;Options passed to copy task execution functions.
/**
* Task execution options
*/
type TaskOptions = {
runTasksInSeries: boolean;
logger: Logger;
handleError: (error: Error) => void;
};Internal task structure used by the plugin during execution.
/**
* Internal task structure for copy operations
*/
interface CopyTask {
source: string;
absoluteSource: string;
destination: string;
absoluteDestination?: string;
context?: string;
toType?: 'dir' | 'file';
options?: CopyActionOptions;
globOptions?: CopyGlobOptions;
}Usage Examples:
// Basic file copy
{
copy: [
{ source: './src/config.json', destination: './dist/config.json' }
]
}
// Directory copy
{
copy: [
{ source: './src/assets', destination: './dist/assets' }
]
}
// Glob pattern copy
{
copy: [
{ source: './src/**/*.js', destination: './dist' },
{ source: './src/**/*.{html,css}', destination: './dist' }
]
}
// Copy with options
{
copy: [
{
source: './src/images',
destination: './dist/assets',
options: {
flat: true,
overwrite: false,
preserveTimestamps: true
}
}
]
}
// Copy with glob options
{
copy: [
{
source: './src/**/*',
destination: './dist',
globOptions: {
dot: true, // Include hidden files
ignore: ['**/*.tmp', '**/*.log']
}
}
]
}
// Copy file into directory (trailing slash indicates directory)
{
copy: [
{ source: './README.md', destination: './dist/' }
]
}/ or is existing directory)*, **, ?, [...]{js,ts}, {file1,file2}