Skip to content

albertopfunk/rollup-plugin-fresh

Repository files navigation

npm NPM

rollup-plugin-fresh

Remove all files or targeted files from a chosen directory

Install

Using npm:

npm install rollup-plugin-fresh --save-dev

Usage

Used as a plugin
Runs when the config is first evaluated

Does not run before rebundling(in watch mode)

import startFresh from 'rollup-plugin-fresh';

plugins: [
  startFresh({
    chosenDir: "./public/",
    deleteAll: false,
    noDeleteOptions: ["global.css", ".html", ".png"],
    quiet: true
  }),
],

Options

chosenDir: "./public/"

deleteAll: false

noDeleteOptions: ["global.css", ".html", ".png"]

quiet: true

chosenDir - Required

Type: String
Default: ""

Relative path starts at the root of your project

You can check the logs if the directory or file(s) are not found

Full relative path is required
Incorrect - "public"
Correct - "./public/"

Other examples
"./public/bundle/"
"./src/some/other/directory/"

deleteAll

Type: Boolean
Default: true

true
Deletes all files in the chosen directory
Skips noDeleteOptions

false
Deletes all files except files that match the noDeleteOptions
Requires noDeleteOptions
Uses Array.prototype.includes() under the hood to match files
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)

noDeleteOptions

Type: Array[...String]
Default: []

Required when javascript deleteAll: false
Since it is using Array.prototype.includes(), you can target files in different ways

["global.css", ".html", ".png", "importantfile.js", "randomName", ".cjs.js"]

quiet

Type: Boolean
Default: false

true
Does not log 'File Removed' activity during removal process
Error logs will still be active

false
logs all activity

About

Clean directories by removing all files or targeted files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published