Building Vue project ignores media subfolders

放肆的年华 提交于 2020-06-29 03:55:50

问题


I am using Vue 2 and I put some videos in the Vue template using HTML5 video.

I save those videos in the VueProjectRootFolder/src/assets/videos/myVideo.mp4 so my markup in Vue is

          <video width="100%" height="40%" controls> 
            <source src="@/assets/videos/myVideo.mp4" type="video/mp4">   
          </video>   

This works and when I do npm run build , the video works. But it is transferred in the media folder and there is no videos subfolder inside. Also, Vue changes the URL of the video to /media/myVideo.mp4

I would like to do npm run build and have a media/videos where all my videos are. And the URL of the videos in the source to change accordingly to media/videos/myVideo.mp4

How can I do this ? Thanks

EDIT

Since docs suggest to use public folder for many files, I also tried to use the public folder. I create a subfolder inside named videos and the source in the markup is

<source src="../../../public/videos/myVideo.mp4" type="video/mp4">

This works if I build Vue, but the public folder is now named media and there is no subfolder inside. The folder videos appears in the root of the app, the same level as media folder and index.html file.

The source now is media/myVideo.mp4

How can I have the videos folder inside the public and have the source be media/videos/myVideos.mp4 ?

来源:https://stackoverflow.com/questions/62408285/building-vue-project-ignores-media-subfolders

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!