0.1.10 • Published 1 year ago

@fnet/rollup-plugin-delete v0.1.10

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
1 year ago

@fnet/rollup-plugin-delete

The @fnet/rollup-plugin-delete is a plugin designed for Rollup, a JavaScript module bundler. Its main purpose is to clean up unnecessary files and folders during the build process by automatically deleting specified targets. This functionality helps maintain a tidy project structure and prevent clutter, especially in continuous integration or build pipelines.

How It Works

The plugin hooks into the Rollup build process and deletes specified files or directories. It can be configured to run just once or every time the build is executed. By specifying targets in the configuration, users can automate the cleanup of files or folders as part of their rollup build process.

Key Features

  • Configurable Execution: Decide whether the plugin should run every build or only once by setting the runOnce option.
  • Target Specification: Specify files or directories to delete during the build using the targets option.
  • Verbose Output: Enable detailed logging to the console with the verbose option, helping track what files are deleted.
  • Dry Run Option: Utilize the dryRun mode to check potential deletions without actually removing files, allowing for safe testing of configurations.

Conclusion

The @fnet/rollup-plugin-delete provides a simple yet effective way to manage file and folder clean-up in Rollup-based projects. By automating the deletion process, it ensures that only relevant files remain, aiding in project organization and simplifying build routines.

@fnet/rollup-plugin-delete Developer Guide

Overview

The @fnet/rollup-plugin-delete is a Rollup plugin designed to help developers automatically delete files or directories during the build process. It offers a straightforward way to clean up build artifacts without manual intervention. This plugin can be particularly useful for maintaining a tidy project directory by removing unnecessary files before or after a build.

Installation

To install the @fnet/rollup-plugin-delete library, use either npm or yarn:

npm install @fnet/rollup-plugin-delete --save-dev

or

yarn add @fnet/rollup-plugin-delete --dev

Usage

Integrate the plugin into your Rollup configuration file. Below is a simple example demonstrating how to use it within a typical Rollup setup:

import deletePlugin from '@fnet/rollup-plugin-delete';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'cjs'
  },
  plugins: [
    deletePlugin({
      targets: ['dist/*'], // Specify files or folders to delete
      runOnce: true,       // Only delete the specified targets once
      verbose: true        // Log deletions to the console
    })
  ]
};

Options

  • targets: An array of strings specifying the files or directories to delete.
  • runOnce: A boolean indicating whether the plugin should execute only once per build session. Defaults to false.
  • verbose: Enable this option to log details of deleted files to the console. Defaults to false.

Examples

Basic Usage

To delete all files within the dist directory before each build:

deletePlugin({
  targets: ['dist/*'],
  verbose: true
});

Run Once Option

To ensure that the deletion only occurs once per build session:

deletePlugin({
  targets: ['build/cache'],
  runOnce: true
});

Dry Run

Perform a dry run to output which files would be deleted without actually removing them:

deletePlugin({
  targets: ['temp/*'],
  verbose: true,
  dryRun: true
});

Acknowledgement

No additional acknowledgments are required for this plugin. It is designed to seamlessly integrate into your Rollup setup and automatically manage file cleanup tasks.

This guide aims to clarify how to effectively use the @fnet/rollup-plugin-delete plugin in your Rollup projects, ensuring a clean and manageable build environment.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  runOnce:
    type: boolean
    description: Whether the plugin should run only once
    default: false
  targets:
    type: array
    items:
      type: string
    description: Files or folders to delete
    default: []
  verbose:
    type: boolean
    description: Whether to log details to the console
    default: false
  dryRun:
    type: boolean
    description: If true, simulates the deletion without actual file removal
required: []
0.1.10

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.9

1 year ago

0.1.4

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.3

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago