我有一个现有的AngularJS应用程序。我想在生产环境中测试应用程序的预览。
步骤1:找到environment.ts文件,检查生产设置为true,
export const environment = {
production: true,
name: 'prod'
};
第2步:转到Main.ts,从'@ angular / core'导入enableProdMode还会导入您的environment.ts文件并添加以下内容,
if (environment.production) {
enableProdMode();
}
步骤3:> ng build --prod(使用此命令来构建您的应用程序,该应用程序将在dist文件夹下生成应用程序的缩小版本)
步骤4:> npm安装angular-http-server(负责运行prod build)还要检查环境变量中的路径变量是否具有其到..npm / node_modules / angular-http-server
的路径。步骤5:> cd dist / proj-folder> angular-http-server
返回已建立并运行产品的端口。