英文:
Copy contents of AddedFiles folder to dist folder, after build
问题
使用React项目在Windows上使用npm构建项目并将内容发布到“dist”文件夹。
一切都按预期运行。
但是我想在项目发布后向dist文件夹添加额外的文件。
到目前为止,我可以使用根目录(src文件夹内部)中的一个单个文件使其正常工作...
"copy": "copy \"robots.txt\" \"dist\"",
(成功将robots.txt复制到dist)
我想复制整个'AddedFiles'文件夹的内容到dist。但是我首先尝试了一个文件,但它说找不到该文件...
"copy": "copy \"\\AddedFiles\\robots.txt\" \"dist\"",
还尝试过
"copy": "copy \"\\.src\\AddedFiles\\robots.txt\" \"dist\"",
->SRC
-robots.txt
->AddedFiles
-robots.txt
请问我做错了什么?
英文:
Using React project on windows with npm to build the project and publish the contents to the 'dist' folder.
All is working as it should.
However I want to add extra files to the dist folder after the project is published.
So far I can get it working with one single file from the root (inside the src folder) so...
"copy": "copy \"robots.txt\" \"dist\"",
(successfully copies robots.txt to dist)
I want to copy the entire contents of 'AddesFiles' folder to dist. But started by trying it with just one file, which says it cant find the file...
"copy": "copy \"\\AddedFiles\\robots.txt\" \"dist\"",
also tried
"copy": "copy \"\\.src\\AddedFiles\\robots.txt\" \"dist\"",
->SRC
-robots.txt
->AddedFiles
-robots.txt
What am I doing wrong please?
答案1
得分: 1
省略前面的反斜杠以获取相对路径:
"copy": "copy \"AddedFiles\\robots.txt\" \"dist\"",
如果您的路径以反斜杠开头:
> 如果[...]目录名以目录分隔符字符开头,则路径相对于当前驱动器的根目录。
...而如果不是:
> 否则,路径相对于当前目录。
要复制文件夹内容,请改用 xcopy
或 robocopy
,例如:
robocopy AddedFiles dist /E
(递归包括子文件夹)
英文:
Omit the leading backslash to get a relative path:
"copy": "copy \"AddedFiles\\robots.txt\" \"dist\"",
If your path starts with a backslash:
> If [...] the directory name begins with the directory separator character, the path is relative from the root of the current drive.
...whereas if it does not:
> Otherwise, the path is relative to the current directory.
To copy a folder content, use xcopy
or robocopy
instead, e.g.:
robocopy AddedFiles dist /E
(include subfolders recursively)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论