无法使用Laravel Mix复制文件夹 [英] Can't copy folders with Laravel Mix
问题描述
我有一个使用 Laravel 5.4 和 Laravel Mix 的项目,并且我有一个images文件夹,其中一些图像名称相同但类别不同,例如它们包含在不同的目录中.
i have a project using Laravel 5.4 and Laravel Mix, and i have an images folder where some of the images have the same name but a different category, as such they are contained within a diferent directory.
所以
resources/
assets/
images/
globalimage.png
versiona/
image1.png
image2.png
versionb/
image1.png
image2.png
我需要的是Laravel Mix中的 copy 命令,以复制这些文件夹以及其中的任何文件,以便我的公用文件夹具有相同的文件夹结构.
What i need is the copy command in Laravel Mix to copy these folders as well as any files within them so that my public folder has the same folder structure.
我该怎么做?
mix.js('resources/assets/backend/js/main.js', 'public/backend/js')
.js('resources/assets/frontend/js/main.js', 'public/frontend/js')
.sass('resources/assets/backend/sass/main.scss', 'public/backend/css')
.sass('resources/assets/frontend/sass/main.scss', 'public/frontend/css')
.sourceMaps()
.copy( 'resources/assets/backend/images/**/*', 'public/backend/images/' )
.copy( 'resources/assets/frontend/images/**/*', 'public/frontend/images/' )
.version()
.disableNotifications();
这是我当前的 Mix 配置文件,我需要更改的部分是那些复制命令
This is my current Mix config file the part i need to change is those copy commands
推荐答案
想通了,copy 命令有第三个参数,它是一个布尔值,用于指定是否展平文件夹结构,如果将其设置为false,则会复制其文件夹结构完整的所有内容.
Figured it out, there's a third parameter to the copy command which is a boolean which specifies whether or not to flatten the folder structure, if you set it to false it'll copy everything with it's folder structure intact.
所以我的Mix配置变为
So my Mix config became
.copy( 'resources/assets/backend/images/', 'public/backend/images/' )
.copy( 'resources/assets/frontend/images/', 'public/frontend/images/', false )
那很好用
这篇关于无法使用Laravel Mix复制文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!