[英]how to run a different html file instead of index.html when webpack server runs?
[英]How to run React application by clicking index.html file without any local server
當我啟動“npm start”時,我使用 create-react-app 創建了反應應用程序,它在瀏覽器中使用 localhost:3000 運行,這很好。 但是,當我從項目文件夾中單擊 index.html 時,它顯示空白頁。 你能給我建議如何使用 index.html 文件運行反應應用程序的解決方案嗎
將"homepage": ".",
添加到package.json
文件的頂部。 然后用yarn build
或npm build
。 Go build/
文件夾並雙擊index.html
。
編輯:
通過index.html打開應用需要
"homepage": "."
inpackage.json
because without it Webpack tries to load the static files from the root the file system rather than build directory. 參考
您可以運行npm run build
,然后運行 go 到“build”文件夾,工作 index.html 將位於該文件夾。 項目文件夾中的 index.html 不是為生產/獨立使用而構建的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.