问题描述
我正在使用这个有角度的4种子应用程序: https://github.com. com/2sic/app-tutorial-angular4-hello-dnn
I'm using this angular 4 seed app: https://github.com/2sic/app-tutorial-angular4-hello-dnn
它使用webpack并可以正常工作.
It uses webpack and works fine.
似乎只提供dev文件,而不是dist/文件夹.
It only seems to serve the dev files and not the dist/ folder.
我要提供dist文件夹.
I want to ng serve the dist folder.
不确定执行此命令的命令或我是否需要安装lite服务器或其他工具.
Not sure the command to do this or if I need to install a lite server or something.
我运行以下命令来创建dist文件夹(可以正常运行):
g build --prod --aot --output-hashing=none
现在,我想在浏览器中运行此版本.
Now I want to run this build in the browser.
推荐答案
您可以使用http服务器来这样做.首先,使用命令ng build --prod --aot --output-hashing=none
生成构建.这将在您的目录结构中创建一个dist文件夹.
You can use http-server for doing so. First of all generate a build using the command ng build --prod --aot --output-hashing=none
. This will create a dist folder in your directory structure.
然后,运行http-server ./dist
,它将开始从dist文件夹提供您的项目.
After this, run http-server ./dist
, which will start serving your project from dist folder.
确保使用
npm install http-server -g
有关参考,请参见 https://www.npmjs.com/package/http-server
这篇关于如何为Angular 2 dist文件夹提供服务index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!