@spinodev/copy-webpack-plugin-cached

6.1.0 • Public • Published

copy-webpack-plugin-cached

This is a personal use fix for the original https://www.npmjs.com/package/copy-webpack-plugin which does not work properly for me.

Changes

I found that the copy plugin just always overwrites the files in my dist directory, so from logging i figured that "compilation.getAsset" and "compilation.updateAsset" weren't recognizing any existing files in the dist folder before the compilation (meaning they only recognized the files after they were copied again during the current compilation).

My fix:

Added a cache file that saves mappings of (filePath, size) using fs. By default the path to this cache file is in node_modules folder, so you should overwrite that location.

Added a new var to the plugin constructor - "cacheLocation" - the path to where you want the cache file to be(including the cache file name).

example:

new CopyPlugin({
    patterns:
        [
            {
                from: path.resolve(__dirname, './assets'),
                to: path.resolve(__dirname, './dist/assets'),
                force: false,
            },
        ]
        , options: {
            cacheLocation: path.resolve(__dirname, "./asset_cache/copy_cache"),
        }
}),

License

All credits and license to the creators of the original plugin: MIT

Package Sidebar

Install

npm i @spinodev/copy-webpack-plugin-cached

Weekly Downloads

9

Version

6.1.0

License

MIT

Unpacked Size

45.9 kB

Total Files

13

Last publish

Collaborators

  • nicodo93
  • irenus