mix.copyWatched()
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Replace console.log to Log.feedback Feb 2, 2019
.gitignore Test _createDestinationFilePath and _createDestinationDirPath methods… Jan 14, 2019
.npmignore Test _createDestinationFilePath and _createDestinationDirPath methods… Jan 14, 2019
LICENSE.txt
README.md Tweak README.md Jan 15, 2019
package-lock.json 2.0.1 Feb 2, 2019
package.json 2.0.1 Feb 2, 2019

README.md

Laravel Mix Copy Watched

This extension provides a copy method that can watch for not only changes but also additions and deletions.

Usage

First, install the extension.

npm install laravel-mix-copy-watched --save-dev

Then, require it within your webpack.mix.js file, like so:

let mix = require('laravel-mix');

require('laravel-mix-copy-watched');

mix
    .js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .copyWatched('resources/images/app.png', 'public/images');

And you're done!

The copyWatched and copyDirectoryWatched methods has the same usage as the copy and copyDirectory methods.

mix.copyWatched(from, to);
mix.copyWatched('from/regex/**/*.txt', to);
mix.copyWatched([path1, path2], to);
mix.copyDirectoryWatched(fromDir, toDir);

With the base option, it is also possible to keep a hierarchical structure (like Gulp).

mix.copyWatched(
    'resources/images/**/*',
    'public/images',
    { base: 'resources/images' }
);