Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

video - Placing mp4 files in public or src folder -> create-react-app Best practices

I am just about to deploy react application and was wondering if I should place a background video in the src or public folder.

I currently have an assets folder in src from which I serve the mp4 background video. Works like a charm on localhost.

I have already googled this question to no avail. The create-react-app documentation doesn't give any advice nor mentions handling of larger video files at all.

Really appreciate if anyone could enlighten me in this topic.

question from:https://stackoverflow.com/questions/65869897/placing-mp4-files-in-public-or-src-folder-create-react-app-best-practices

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As it is suggested in the documentation:

If you put a file into the public folder, it will not be processed by webpack. Instead, it will be copied into the build folder untouched.

It's better to put these kinds of files into the public folder in order not to be engaged with FileLoader of Webpack on the build process, however, you can also use the assets folder but webpack will consider them as assets and will add a chunk hash at the end and put the reference in the bundle which will be created.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...