or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

archive.mdconfiguration.mdcopy.mddelete.mdindex.mdmkdir.mdmove.md
tile.json

tessl/npm-filemanager-webpack-plugin

Webpack plugin to copy, archive (.zip), move, delete files and directories before and after builds

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/filemanager-webpack-plugin@9.0.x

To install, run

npx @tessl/cli install tessl/npm-filemanager-webpack-plugin@9.0.0

index.mddocs/

FileManager Webpack Plugin

The FileManager Webpack Plugin enables comprehensive file management operations during Webpack builds. It provides the ability to copy, move, delete, create directories, and archive files and directories before (onStart) or after (onEnd) the bundling process, with support for glob patterns, parallel/serial execution, and extensive configuration options.

Package Information

  • Package Name: filemanager-webpack-plugin
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install filemanager-webpack-plugin --save-dev

Core Imports

import FileManagerPlugin from "filemanager-webpack-plugin";

For CommonJS:

const FileManagerPlugin = require("filemanager-webpack-plugin");

Basic Usage

import FileManagerPlugin from "filemanager-webpack-plugin";

// In webpack.config.js
export default {
  plugins: [
    new FileManagerPlugin({
      events: {
        onStart: {
          delete: ['./dist'],
          mkdir: ['./dist/assets']
        },
        onEnd: {
          copy: [
            { source: './src/assets', destination: './dist/assets' },
            { source: './README.md', destination: './dist/README.md' }
          ],
          archive: [
            { source: './dist', destination: './dist/app.zip' }
          ]
        }
      }
    })
  ]
};

Architecture

The FileManager Webpack Plugin is built around several key components:

  • Plugin Class: Main FileManagerPlugin class that implements Webpack's plugin interface
  • Event System: Hooks into Webpack's lifecycle with onStart and onEnd events
  • Action System: Five distinct file operations (copy, delete, move, mkdir, archive)
  • Task Execution: Configurable parallel/serial execution with error handling
  • Path Resolution: Automatic resolution of relative paths based on Webpack context

Capabilities

Plugin Configuration

Core plugin configuration interface and options for controlling execution behavior.

interface FileManagerPluginOptions {
  events?: {
    onStart?: Actions | Actions[];
    onEnd?: Actions | Actions[];
  };
  runTasksInSeries?: boolean;
  runOnceInWatchMode?: boolean;
  context?: string | null;
  throwOnError?: boolean;
}

interface Actions {
  copy?: CopyAction[];
  delete?: DeleteAction[];
  move?: MoveAction[];
  mkdir?: MkdirAction[];
  archive?: ArchiveAction[];
}

Plugin Configuration

Copy Operations

Copy individual files or entire directories with glob pattern support and flexible destination handling.

interface CopyAction {
  source: string;
  destination: string;
  options?: CopyActionOptions;
  globOptions?: CopyGlobOptions;
}

interface CopyActionOptions {
  flat?: boolean;
  overwrite?: boolean;
  preserveTimestamps?: boolean;
}

Copy Operations

Delete Operations

Delete individual files or entire directories with support for glob patterns and del package options.

type DeleteAction = string | {
  source: string;
  options: DeleteOptions;
};

Delete Operations

Move Operations

Move individual files or entire directories from source to destination locations.

interface MoveAction {
  source: string;
  destination: string;
}

Move Operations

Directory Creation

Create directory paths with full recursive support.

type MkdirAction = string;

Directory Creation

Archive Operations

Create archives (zip/tar) from files, directories, or glob patterns with extensive archiver.js options.

interface ArchiveAction {
  source: string;
  destination: string;
  format?: 'zip' | 'tar';
  options?: ArchiverOptions;
}

Archive Operations

Plugin Class

/**
 * Main FileManager Webpack Plugin class
 */
class FileManagerPlugin {
  constructor(options: FileManagerPluginOptions);
  apply(compiler: Compiler): void;
}

export default FileManagerPlugin;
export interface FileManagerPluginOptions;