Joaquín L. Robles
Joaquín L. Robles

Reputation: 6494

mix.copyDirectory is not a function in Laravel Elixir 5

According to the docs, in order to maintain the directory's structure I should use copyDirectory but I obtain the following:

/webpack.mix.js:16
   .copyDirectory('resources/assets/bower', 'public/js');
    ^

TypeError: mix.js(...).sass(...).copyDirectory is not a function

This is my webpack file:

const { mix } = require('laravel-mix');

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css')
   .copyDirectory('resources/assets/bower', 'public/js');

Any ideas? Thanks

Upvotes: 2

Views: 2453

Answers (2)

Hyder B.
Hyder B.

Reputation: 12246

I have got the same error message.

TypeError: mix.copyDirectory is not a function

Actually, it's because you were using an old version of Laravel mix that does not support the mix.copyDirectory.

All you have to do is:

npm install laravel-mix@^1.0 --save-dev
npm run dev

Upvotes: 0

Joaquín L. Robles
Joaquín L. Robles

Reputation: 6494

Nevermid, the docs aren't correct: you should pass false to the copy funcion, as follows:

mix.copy('resources/assets/bower', 'public/js', false);

This way it won't flatten the source directory

Upvotes: 5

Related Questions