[英]How can I change the path/file name of index.html in React?
When building a React (with usual react-scripts
/ create-creact-app
etc.) app via npm build
, I always get the entry file in build/index.html
. 当通过
npm build
构建一个React(带有通常的react-scripts
/ create-creact-app
等)应用时,我总是在build/index.html
获得入口文件。
I've tried moving the src
into a subfolder, but the index.js
is required to be there in src/index.js
. 我试过将
src
移到子文件夹中,但index.js
必须在src/index.js
。
So how can I change the output path of the index.html
? 那么, 如何更改
index.html
的输出路径?
Ie eg I want to rename it to index.htm
, because I am have a pedantic quirk, or I want to change the output path to build/srv/www/index.html
? 即例如我想将其重命名为
index.htm
,因为我有一个古怪的怪癖,或者我想将输出路径更改为build/srv/www/index.html
?
(These are just examples.) (这些只是示例。)
To change the output path you need to change the webpack config, and in create-react-path is not possible unless you run the eject script. 要更改输出路径,您需要更改webpack配置,并且除非您运行弹出脚本,否则在create-react-path中是不可能的。
This way: 这条路:
npm run eject
After running it, you will be able to access to any project configuration (webpack config in your case), but you must know, once the project is ejected, you can't go back. 运行它之后,您将可以访问任何项目配置(您的情况下为webpack config),但是必须知道,一旦项目退出,就无法返回。
More information here: 此处的更多信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.