问题描述
我正在使用这个 angular 4 种子应用程序:https://github.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.
不确定执行此操作的命令,或者我是否需要安装精简版服务器或其他东西.
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-server 来执行此操作.首先使用命令 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!