{"id":13548275,"url":"https://github.com/gregnb/filemanager-webpack-plugin","last_synced_at":"2025-05-14T22:08:33.844Z","repository":{"id":41092848,"uuid":"101706034","full_name":"gregnb/filemanager-webpack-plugin","owner":"gregnb","description":"Copy, move, archive (zip/tar/tar.gz), delete files and directories before and after Webpack builds. Win32/Mac/*Nix supported","archived":false,"fork":false,"pushed_at":"2024-09-27T01:58:37.000Z","size":1848,"stargazers_count":464,"open_issues_count":8,"forks_count":35,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T10:01:20.215Z","etag":null,"topics":["javascript","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregnb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["sibiraj-s"]}},"created_at":"2017-08-29T01:46:17.000Z","updated_at":"2025-04-02T08:22:03.000Z","dependencies_parsed_at":"2024-06-18T12:22:05.156Z","dependency_job_id":"c201c35c-0483-414b-895c-63a14eee0f34","html_url":"https://github.com/gregnb/filemanager-webpack-plugin","commit_stats":{"total_commits":285,"total_committers":19,"mean_commits":15.0,"dds":0.4491228070175438,"last_synced_commit":"3332ff31b8434df1471137b7b4242c6a4b11653f"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregnb%2Ffilemanager-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregnb%2Ffilemanager-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregnb%2Ffilemanager-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregnb%2Ffilemanager-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregnb","download_url":"https://codeload.github.com/gregnb/filemanager-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235700,"owners_count":22036964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","webpack","webpack-plugin"],"created_at":"2024-08-01T12:01:08.129Z","updated_at":"2025-05-14T22:08:28.826Z","avatar_url":"https://github.com/gregnb.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"assets/filemanager.png\" /\u003e\n  \u003ch1\u003eFileManager Webpack Plugin\u003c/h1\u003e\n  \u003cp\u003eThis Webpack plugin allows you to copy, archive (.zip/.tar/.tar.gz), move, delete files and directories before and after builds\u003c/p\u003e\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/gregnb/filemanager-webpack-plugin/actions?query=workflow%3ATests\" alt=\"Testst\"\u003e\n      \u003cimg src=\"https://github.com/gregnb/filemanager-webpack-plugin/workflows/Tests/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://npmcharts.com/compare/filemanager-webpack-plugin?minimal=true\" alt=\"NPM weekly downloads\"\u003e\n      \u003cimg src=\"https://badgen.net/npm/dw/filemanager-webpack-plugin\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.npmtrends.com/filemanager-webpack-plugin\" alt=\"NPM total downloads\"\u003e\n      \u003cimg src=\"https://badgen.net/npm/dt/filemanager-webpack-plugin\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://npmjs.com/filemanager-webpack-plugin\" alt=\"NPM version\"\u003e\n      \u003cimg src=\"https://badgen.net/npm/v/filemanager-webpack-plugin\"\u003e\n    \u003c/a\u003e\n     \u003ca href=\"https://npmjs.com/filemanager-webpack-plugin\" alt=\"Node version\"\u003e\n      \u003cimg src=\"https://badgen.net/npm/node/filemanager-webpack-plugin\"\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## Install\n\n```bash\nnpm install filemanager-webpack-plugin --save-dev\n# or\nyarn add filemanager-webpack-plugin --dev\n```\n\n## Usage\n\n```js\n// webpack.config.js:\n\nconst FileManagerPlugin = require('filemanager-webpack-plugin');\n\nexport default {\n  // ...rest of the config\n  plugins: [\n    new FileManagerPlugin({\n      events: {\n        onEnd: {\n          copy: [\n            { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },\n            { source: '/path/**/*.js', destination: '/path' },\n          ],\n          move: [\n            { source: '/path/from', destination: '/path/to' },\n            { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },\n          ],\n          delete: ['/path/to/file.txt', '/path/to/directory/'],\n          mkdir: ['/path/to/directory/', '/another/directory/'],\n          archive: [\n            { source: '/path/from', destination: '/path/to.zip' },\n            { source: '/path/**/*.js', destination: '/path/to.zip' },\n            { source: '/path/fromfile.txt', destination: '/path/to.zip' },\n            { source: '/path/fromfile.txt', destination: '/path/to.zip', format: 'tar' },\n            {\n              source: '/path/fromfile.txt',\n              destination: '/path/to.tar.gz',\n              format: 'tar',\n              options: {\n                gzip: true,\n                gzipOptions: {\n                  level: 1,\n                },\n                globOptions: {\n                  // https://github.com/Yqnn/node-readdir-glob#options\n                  dot: true,\n                },\n              },\n            },\n          ],\n        },\n      },\n    }),\n  ],\n};\n```\n\n# Options\n\n```js\nnew FileManagerPlugin({\n  events: {\n    onStart: {},\n    onEnd: {},\n  },\n  runTasksInSeries: false,\n  runOnceInWatchMode: false,\n});\n```\n\n## File Events\n\n- `onStart`: Commands to execute before Webpack begins the bundling process\n\n**Note:**\n\nOnStart might execute twice for file changes in webpack context.\n\n```js\nnew webpack.WatchIgnorePlugin({\n  paths: [/copied-directory/],\n});\n```\n\n- `onEnd`: Commands to execute after Webpack has finished the bundling process\n\n## File Actions\n\n### Copy\n\nCopy individual files or entire directories from a source folder to a destination folder. Also supports glob pattern.\n\n```js\n[\n  { source: '/path/from', destination: '/path/to' },\n  {\n    source: '/path/**/*.js',\n    destination: '/path',\n    options: {\n      flat: false,\n      preserveTimestamps: true,\n      overwrite: true,\n    },\n    globOptions: {\n      dot: true,\n    },\n  },\n  { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },\n  { source: '/path/**/*.{html,js}', destination: '/path/to' },\n  { source: '/path/{file1,file2}.js', destination: '/path/to' },\n];\n```\n\n**Options**\n\n- source[`string`] - a file or a directory or a glob\n- destination[`string`] - a file or a directory.\n- options [`object`] - copy options\n- globOptions [`object`] - options to forward to glob options([See available options here](https://github.com/Yqnn/node-readdir-glob#options))\n\n**Caveats**\n\n- if source is a `glob`, destination must be a directory\n- if source is a `file` and destination is a directory, the file will be copied into the directory\n\n### Delete\n\nDelete individual files or entire directories. Also supports glob pattern\n\n```js\n['/path/to/file.txt', '/path/to/directory/', '/another-path/to/directory/**.js'];\n```\n\nor\n\n```js\n[\n  {\n    source: '/path/to/file.txt',\n    options: {\n      force: true,\n    },\n  },\n];\n```\n\n### Move\n\nMove individual files or entire directories.\n\n```js\n[\n  { source: '/path/from', destination: '/path/to' },\n  { source: '/path/fromfile.txt', destination: '/path/tofile.txt' },\n];\n```\n\n**Options**\n\n- source[`string`] - a file or a directory or a glob\n- destination[`string`] - a file or a directory.\n\n### Mkdir\n\nCreate a directory path with given path\n\n```js\n['/path/to/directory/', '/another/directory/'];\n```\n\n### Archive\n\nArchive individual files or entire directories. Defaults to .zip unless 'format' and 'options' provided. Uses [node-archiver](https://github.com/archiverjs/node-archiver)\n\n```js\n[\n  { source: '/path/from', destination: '/path/to.zip' },\n  { source: '/path/**/*.js', destination: '/path/to.zip' },\n  { source: '/path/fromfile.txt', destination: '/path/to.zip' },\n  { source: '/path/fromfile.txt', destination: '/path/to.zip', format: 'tar' },\n  {\n    source: '/path/fromfile.txt',\n    destination: '/path/to.tar.gz',\n    format: 'tar', // optional\n    options: {\n      // see https://www.archiverjs.com/docs/archiver\n      gzip: true,\n      gzipOptions: {\n        level: 1,\n      },\n      globOptions: {\n        // https://github.com/Yqnn/node-readdir-glob#options\n        dot: true,\n      },\n    },\n  },\n];\n```\n\n- source[`string`] - a file or a directory or a glob\n- destination[`string`] - a file.\n- format[`string`] - Optional. Defaults to extension in destination filename.\n- options[`object`] - Refer https://www.archiverjs.com/archiver\n\n### Order of execution\n\nIf 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:\n\n```js\n{\n  onEnd: [\n    {\n      copy: [{ source: './dist/bundle.js', destination: './newfile.js' }],\n    },\n    {\n      delete: ['./dist/bundle.js'],\n    },\n  ];\n}\n```\n\n## Other Options\n\n- **runTasksInSeries** [`boolean`] - Run tasks in series. Defaults to false\n- **runOnceInWatchMode** [`boolean`] - The `onStart` event will be run only once in watch mode. Defaults to false\n\nFor Example, the following will run one after the other\n\n```js\ncopy: [\n  { source: 'dist/index.html', destination: 'dir1/' },\n  { source: 'dir1/index.html', destination: 'dir2/' },\n];\n```\n\n- **context** [`string`] - The directory, an absolute path, for resolving files. Defaults to [webpack context](https://webpack.js.org/configuration/entry-context/#context).\n\n## Related plugins\n\n- [copy-asset-in-memory-webpack-plugin](https://github.com/sibiraj-s/copy-asset-in-memory-webpack-plugin)\n- [replace-asset-name-webpack-plugin](https://github.com/sibiraj-s/replace-asset-name-webpack-plugin)\n","funding_links":["https://github.com/sponsors/sibiraj-s"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregnb%2Ffilemanager-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregnb%2Ffilemanager-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregnb%2Ffilemanager-webpack-plugin/lists"}