按照有关在生产模式下本地部署应用程序的Angular教程进行操作后,即使使用示例应用程序,我也未能做到。 步骤:
ng new prod-app
ng build --prod
http-server /dist/prod-app
<-在教程中使用lite-server --baseDir="dist/prod-proj"
<-在Angular文档中同时使用两个服务器会导致相同的行为,空白页并显示404错误
F:\AngularApps\prod-proj>lite-server --baseDir="dist"
Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
** browser-sync config **
{ injectChanges: false,
files: [ './**/*.{html,htm,css,js}' ],
watchOptions: { ignored: 'node_modules' },
server: { baseDir: 'dist', middleware: [ [Function], [Function] ] } }
[Browsersync] Access URLs:
-------------------------------------
Local: http://localhost:3000
External: http://192.168.56.1:3000
-------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
-------------------------------------
[Browsersync] Serving files from: dist
[Browsersync] Watching files...
19.08.16 08:49:20 404 GET /index.html
19.08.16 08:49:20 404 GET /favicon.ico
教程和文档中都没有关于任何额外配置的内容,那么我缺少什么?
谢谢, 加多(Gado)
答案 0 :(得分:0)
在精简服务器输出中,您已指定baseDir="dist"
,将其更改为baseDir="dist/prod-proj"
F:\AngularApps\prod-proj>lite-server --baseDir="dist/prod-proj"