rollup-plugin-mv

A Rollup plugin to move around generated files and directories

Usage no npm install needed!

<script type="module">
  import rollupPluginMv from 'https://cdn.skypack.dev/rollup-plugin-mv';
</script>

README

rollup-plugin-mv

🍣 A Rollup plugin to move around generated files and directories

Requirements

This plugin requires an LTS Node version (v8.0.0+) and Rollup

Install

Using npm:

npm install rollup-plugin-mv --save-dev

Usage

Create a rollup.config.js configuration file and import the plugin:

import mv from "rollup-plugin-mv";

export default {
  input: "src/index.js",
  output: {
    dir: "output",
    format: "cjs",
  },
  plugins: [
    mv(
      [
        { src: "dist/file", dist: "dist/assets/file" },
        {
          src: "dist/folder",
          dist: "dist/assets/dir",
          overwrite: true,
        },
      ],
      {
        overwrite: false,
      }
    ),
  ],
};

The first argument accepts an object or an array of objects with the following shape:

{
  /**
   * Source file or directory
   */
  src: string;
  /**
   * Destination file or directory
   */
  dist: string;
  /**
   * Overwrite existing file or directory.
   */
  overwrite?: boolean;
}

Options

overwrite

Type: boolean
Default: false

Overwrite existing file or directory.

once

Type: boolean
Default: false

Executes the move command only once even if there are multiple outputs.