6.1.0 • Published 3 years ago

@spinodev/copy-webpack-plugin-cached v6.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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