All Projects โ†’ gregnb โ†’ Filemanager Webpack Plugin

gregnb / Filemanager Webpack Plugin

Licence: mit
Copy, move, archive (zip/tar/tar.gz), delete files and directories before and after Webpack builds. Win32/Mac/*Nix supported

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Filemanager Webpack Plugin

Wxapp Webpack Plugin
๐Ÿ“ฆ ๅพฎไฟกๅฐ็จ‹ๅบ webpack ๆ’ไปถ
Stars: โœญ 185 (-40.32%)
Mutual labels:  webpack, webpack-plugin
Critters
๐Ÿฆ” A Webpack plugin to inline your critical CSS and lazy-load the rest.
Stars: โœญ 2,894 (+833.55%)
Mutual labels:  webpack, webpack-plugin
Bundle Buddy Webpack Plugin
๐Ÿ๐Ÿ๐Ÿ๐Ÿ bundle-buddy-webpack-plugin ๐Ÿ๐Ÿ๐Ÿ๐Ÿ
Stars: โœญ 199 (-35.81%)
Mutual labels:  webpack, webpack-plugin
Html Res Webpack Plugin
plugin for generating html in webpack
Stars: โœญ 170 (-45.16%)
Mutual labels:  webpack, webpack-plugin
Webpack Assets Manifest
This Webpack plugin will generate a JSON file that matches the original filename with the hashed version.
Stars: โœญ 269 (-13.23%)
Mutual labels:  webpack, webpack-plugin
Workerize Loader
๐Ÿ—๏ธ Automatically move a module into a Web Worker (Webpack loader)
Stars: โœญ 2,135 (+588.71%)
Mutual labels:  webpack, webpack-plugin
Hard Source Webpack Plugin
www.npmjs.com/package/hard-source-webpack-plugin
Stars: โœญ 2,608 (+741.29%)
Mutual labels:  webpack, webpack-plugin
Virtual Module Webpack Plugin
Adds the contents of a virtual file to webpack's cached file system without writing it to disk
Stars: โœญ 165 (-46.77%)
Mutual labels:  webpack, webpack-plugin
Webpack Shell Plugin
Run shell commands either before or after webpack builds
Stars: โœญ 250 (-19.35%)
Mutual labels:  webpack, webpack-plugin
Webpack Messages
Beautifully format Webpack messages throughout your bundle lifecycle(s)!
Stars: โœญ 238 (-23.23%)
Mutual labels:  webpack, webpack-plugin
React Core Boilerplate
Powerful ASP.NET Core 3 templates with React, true server-side rendering and Docker support
Stars: โœญ 169 (-45.48%)
Mutual labels:  webpack, webpack-plugin
Webpack Sentry Plugin
Webpack plugin to upload source maps to Sentry
Stars: โœญ 299 (-3.55%)
Mutual labels:  webpack, webpack-plugin
Multipage Webpack Plugin
A plugin that makes handling templates and asset distribution for multi-page applications using webpack trivial
Stars: โœญ 168 (-45.81%)
Mutual labels:  webpack, webpack-plugin
Emojify Webpack Plugin
๐Ÿฆ„ Turn your code into emoji
Stars: โœญ 178 (-42.58%)
Mutual labels:  webpack, webpack-plugin
Webpack.js.org
Repository for webpack documentation and more!
Stars: โœญ 2,049 (+560.97%)
Mutual labels:  webpack, webpack-plugin
Unused Files Webpack Plugin
Glob all files that are not compiled by webpack under webpack's context
Stars: โœญ 210 (-32.26%)
Mutual labels:  webpack, webpack-plugin
Clean Webpack Plugin
By default, this plugin will remove all files inside webpack's output.path directory, as well as all unused webpack assets after every successful rebuild.
Stars: โœญ 1,888 (+509.03%)
Mutual labels:  webpack, webpack-plugin
Svg Spritemap Webpack Plugin
SVG spritemap plugin for webpack
Stars: โœญ 160 (-48.39%)
Mutual labels:  webpack, webpack-plugin
Copy Webpack Plugin
Copy files and directories with webpack
Stars: โœญ 2,679 (+764.19%)
Mutual labels:  webpack, webpack-plugin
Webpack Virtual Modules
Webpack Virtual Modules is a webpack plugin that lets you create, modify, and delete in-memory files in a way that webpack treats them as if they were physically presented in the file system.
Stars: โœญ 286 (-7.74%)
Mutual labels:  webpack, webpack-plugin

FileManager Webpack Plugin

This Webpack plugin allows you to copy, archive (.zip/.tar/.tar.gz), move, delete files and directories before and after builds

Install

npm install filemanager-webpack-plugin --save-dev
# or
yarn add filemanager-webpack-plugin --dev

Usage

// webpack.config.js:

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

module.exports = {
  plugins: [
    new FileManagerPlugin({
      events: {
        onEnd: {
          copy: [
            { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },
            { source: '/path/**/*.js', destination: '/path' },
          ],
          move: [
            { source: '/path/from', destination: '/path/to' },
            { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },
          ],
          delete: ['/path/to/file.txt', '/path/to/directory/'],
          mkdir: ['/path/to/directory/', '/another/directory/'],
          archive: [
            { source: '/path/from', destination: '/path/to.zip' },
            { source: '/path/**/*.js', destination: '/path/to.zip' },
            { source: '/path/fromfile.txt', destination: '/path/to.zip' },
            { source: '/path/fromfile.txt', destination: '/path/to.zip', format: 'tar' },
            {
              source: '/path/fromfile.txt',
              destination: '/path/to.tar.gz',
              format: 'tar',
              options: {
                gzip: true,
                gzipOptions: {
                  level: 1,
                },
                globOptions: {
                  nomount: true,
                },
              },
            },
          ],
        },
      },
    }),
  ],
};

Options

new FileManagerPlugin({
  events: {
    onStart: {},
    onEnd: {},
  },
  runTasksInSeries: false,
});

File Events

  • onStart: Commands to execute before Webpack begins the bundling process

Note:

OnStart might execute twice for file changes in webpack context.

new webpack.WatchIgnorePlugin({
  paths: [/copied-directory/],
});
  • onEnd: Commands to execute after Webpack has finished the bundling process

File Actions

Copy

Copy individual files or entire directories from a source folder to a destination folder. Also supports glob pattern.

[
  { source: '/path/from', destination: '/path/to' },
  { source: '/path/**/*.js', destination: '/path' },
  { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },
  { source: '/path/**/*.{html,js}', destination: '/path/to' },
  { source: '/path/{file1,file2}.js', destination: '/path/to' },
];

Options

  • source[string] - a file or a directory or a glob
  • destination[string] - a file or a directory.

Caveats

  • if source is a glob, destination must be a directory
  • if souce is a file and destination is a directory, the file will be copied into the directory

Delete

Delete individual files or entire directories. Also supports glob pattern

['/path/to/file.txt', '/path/to/directory/', '/another-path/to/directory/**.js'];

or

[
  {
    source: '/path/to/file.txt',
    options: {
      force: true,
    },
  },
];

Move

Move individual files or entire directories.

[
  { source: '/path/from', destination: '/path/to' },
  { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },
];

Options

  • source[string] - a file or a directory or a glob
  • destination[string] - a file or a directory.

Mkdir

Create a directory path with given path

['/path/to/directory/', '/another/directory/'];

Archive

Archive individual files or entire directories. Defaults to .zip unless 'format' and 'options' provided. Uses node-archiver

[
  { source: '/path/from', destination: '/path/to.zip' },
  { source: '/path/**/*.js', destination: '/path/to.zip' },
  { source: '/path/fromfile.txt', destination: '/path/to.zip' },
  { source: '/path/fromfile.txt', destination: '/path/to.zip', format: 'tar' },
  {
    source: '/path/fromfile.txt',
    destination: '/path/to.tar.gz',
    format: 'tar', // optional
    options: {
      // see https://www.archiverjs.com/archiver
      gzip: true,
      gzipOptions: {
        level: 1,
      },
      globOptions: {
        nomount: true,
      },
    },
  },
];
  • source[string] - a file or a directory or a glob
  • destination[string] - a file.
  • format[string] - Optional. Defaults to extension in destination filename.
  • options[object] - Refer https://www.archiverjs.com/archiver

Order of execution

If you need to preserve the order in which operations will run you can set the onStart and onEnd events to be Arrays. In this example below, in the onEnd event the copy action will run first, and then the delete after:

{
  onEnd: [
    {
      copy: [{ source: './dist/bundle.js', destination: './newfile.js' }],
    },
    {
      delete: ['./dist/bundle.js'],
    },
  ];
}

Other Options

  • runTasksInSeries [boolean] - Run tasks in series. Defaults to false

For Example, the following will run one after the other

copy: [
  { source: 'dist/index.html', destination: 'dir1/' },
  { source: 'dir1/index.html', destination: 'dir2/' },
];
  • context [string] - The directory, an absolute path, for resolving files. Defaults to webpack context.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].