Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Elixir: How to mix copy multiple files

How do I mix copy multiple files with Elixir?

This does not work:

mix.copy([
    ['node_modules/vue/dist/vue.js', 'resources/assets/js/vendor/vue.js'],
    ['node_modules/vue-resource/dist/vue-resource.js', 'resources/assets/js/vendor/vue-resource.js']
]);

Any other suggestions except:

mix.copy('node_modules/vue/dist/vue.js', 'resources/assets/js/vendor/vue.js');
mix.copy('node_modules/vue-resource/dist/vue-resource.js', 'resources/assets/js/vendor/vue-resource.js');
like image 994
LoveAndHappiness Avatar asked Mar 15 '23 05:03

LoveAndHappiness


1 Answers

The problem is that mix.copy() expect two strings so passing an array will not work. I fixed it by creating an object called directories like this:

var directories = {
  'node_modules/vue/dist/vue.js': 'resources/assets/js/vendor/vue.js',
  'node_modules/vue-resource/dist/vue-resource.js': 'resources/assets/js/vendor/vue-resource.js'
}

Then we can loop on that object like this:

for (directory in directories) {
  mix.copy(directory, directories[directory]);
}

This should work.

like image 161
Ahmad Alfy Avatar answered Mar 23 '23 22:03

Ahmad Alfy