We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在编译一个用 Create React App 写的项目时,控制台说可以配置 package.json 文件中的 homepage 字段,来指定编译后的静态资源的路径。
package.json
homepage
Google package.json homepage field,找到了官方文档 Building for Relative Paths ,在 package.json 文件中配置 homepage 字段,即可指定 build 阶段所有静态资源相对于 index.html 的路径。
package.json homepage field
index.html
默认情况下 package.json 中没有配置该字段,Create React App 认为网站部署在根目录下,index.html 中引用的静态资源路径都是 /static 这种绝对路径。
/static
如果配置为 homepage: '.',那么 index.html 中的所有静态资源则都是相对路径,在编译后的 index.html 中可以看到静态资源的路径为 ./static。
homepage: '.'
./static
The text was updated successfully, but these errors were encountered:
No branches or pull requests
需求
在编译一个用 Create React App 写的项目时,控制台说可以配置
package.json
文件中的homepage
字段,来指定编译后的静态资源的路径。方案
Google
package.json homepage field
,找到了官方文档 Building for Relative Paths ,在package.json
文件中配置homepage
字段,即可指定 build 阶段所有静态资源相对于index.html
的路径。默认情况下
package.json
中没有配置该字段,Create React App 认为网站部署在根目录下,index.html
中引用的静态资源路径都是/static
这种绝对路径。如果配置为
homepage: '.'
,那么index.html
中的所有静态资源则都是相对路径,在编译后的index.html
中可以看到静态资源的路径为./static
。The text was updated successfully, but these errors were encountered: