Comprehensive configuration options for the FileManager Webpack Plugin, including event handling, execution control, and context management.
Primary configuration interface for the FileManager Plugin.
/**
* Main configuration interface for FileManager Plugin
*/
interface FileManagerPluginOptions {
/** Event-based action configuration */
events?: {
/** Actions to execute before Webpack bundling */
onStart?: Actions | Actions[];
/** Actions to execute after Webpack bundling */
onEnd?: Actions | Actions[];
};
/** Run tasks in series instead of parallel (default: false) */
runTasksInSeries?: boolean;
/** Run tasks only once in watch mode (default: false) */
runOnceInWatchMode?: boolean;
/** Base directory for resolving relative paths (default: webpack context) */
context?: string | null;
/** Throw error if any action fails (default: false) */
throwOnError?: boolean;
}Container interface for all available file operations.
/**
* Container for all file management actions
*/
interface Actions {
/** Copy operations */
copy?: CopyAction[];
/** Delete operations */
delete?: DeleteAction[];
/** Move operations */
move?: MoveAction[];
/** Directory creation operations */
mkdir?: MkdirAction[];
/** Archive operations */
archive?: ArchiveAction[];
}const defaultOptions: FileManagerPluginOptions = {
events: {
onStart: [],
onEnd: []
},
runTasksInSeries: false,
context: null,
runOnceInWatchMode: false,
throwOnError: false
};/**
* Main FileManager Webpack Plugin class
*/
class FileManagerPlugin {
constructor(options: FileManagerPluginOptions);
apply(compiler: Compiler): void;
}Usage Examples:
import FileManagerPlugin from "filemanager-webpack-plugin";
// Basic configuration
const basicPlugin = new FileManagerPlugin({
events: {
onEnd: {
copy: [{ source: './src', destination: './dist' }]
}
}
});
// Advanced configuration
const advancedPlugin = new FileManagerPlugin({
events: {
onStart: {
delete: ['./dist']
},
onEnd: {
copy: [{ source: './assets', destination: './dist/assets' }],
archive: [{ source: './dist', destination: './release.zip' }]
}
},
runTasksInSeries: true,
runOnceInWatchMode: true,
context: '/absolute/path/to/project',
throwOnError: true
});
// Multiple action sets (executed in order)
const orderedPlugin = new FileManagerPlugin({
events: {
onEnd: [
{
copy: [{ source: './dist/bundle.js', destination: './backup.js' }]
},
{
delete: ['./dist/bundle.js']
}
]
}
});runOnceInWatchMode: true to prevent multiple executionstrue, tasks within an action run sequentiallytrue, onStart events run only once in watch modetrue, compilation fails if any action failsprocess.cwd()