![](/img/trans.png)
[英]Angular 6 'ng build --prod' is not minifying/uglifying the index.html
[英]how to run the index.html file after ng build --prod
我使用以下命令創建了一個新的 angular 應用程序:
ng new angularapp
之后,我使用此命令生成了一個 dist 文件夾。
ng build --prod
之后,我嘗試打開 dist 文件夾中的 index.html 文件,但出現此錯誤:
您需要有一個正在運行的 http 服務器才能在構建后查看應用程序
如果您不想在本地瀏覽器中查看應用程序,則可以使用 VS 代碼擴展Live Server等工具運行服務器
您還可以安裝 run 並運行本地 apache 服務器,並將文件放在根文件夾中,然后使用 Wamp、Xamp 或 Lamp 等工具訪問 localhost。
或者
你可以使用http-server
npm 包來做到這一點。
第 1 步:首先全局安裝軟件包
npm install http-server -g
。
第 2 步:然后在您的項目目錄中(在終端中)運行
http-server dist/.
如果您使用的是 angular 6.xx,則必須運行
http-server dist/your-project-name
現在您可以訪問http://localhost:8080查看您的應用程序
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.