dist/main-[es-version].[hash].js 您的应用程序捆绑了 [ ES5 大小:135 KB 新的 Angular CLI 应用程序为空,38 KB压缩].dist/polyfill-[es-version].[hash].bundle.js 捆绑的 polyfill 依赖项(@angular、RxJS...)[ ES5 大小:36 KB 用于新的 Angular CLI应用程序为空,12 KB 压缩].dist/index.html 应用程序的入口点.dist/runtime-[es-version].[hash].bundle.js webpack 加载器dist/style.[hash].bundle.css 样式定义dist/assets 从 Angular CLI 资产配置复制的资源部署您可以使用 ng serve --prod 命令获取应用程序的预览,该命令启动本地 HTTP 服务器,以便可以使用 http 访问带有生产文件的应用程序://本地主机:4200.将其用于生产用途是不安全的.对于生产用途,您必须在您选择的 HTTP 服务器中部署 dist 文件夹中的所有文件.What is the best method to bundle Angular (version 2, 4, 6, ...) for production on a live web server.Please include the Angular version within answers so we can track better when it moves to later releases. 解决方案 2 to 11 (TypeScript) with Angular CLIOneTime Setupnpm install -g @angular/cling new projectFolder creates a new applicationBundling Stepng build --prod (run in command line when directory is projectFolder)flag prod bundle for production (see the Angular documentation for the list of option included with the production flag).Compress using Brotli compression the resources using the following commandfor i in dist/*/*; do brotli $i; donebundles are generated by default to projectFolder/dist(/$projectFolder for v6+)**OutputSizes with Angular 11.2.12 with CLI 11.2.12and option CSS without Angular routingdist/main-[es-version].[hash].js Your application bundled [ ES5 size: 135 KB for new Angular CLI application empty, 38 KB compressed].dist/polyfill-[es-version].[hash].bundle.js the polyfill dependencies (@angular, RxJS...) bundled [ ES5 size: 36 KB for new Angular CLI application empty, 12 KB compressed].dist/index.html entry point of your application.dist/runtime-[es-version].[hash].bundle.js webpack loaderdist/style.[hash].bundle.css the style definitionsdist/assets resources copied from the Angular CLI assets configurationDeploymentYou can get a preview of your application using the ng serve --prod command that starts a local HTTP server such that the application with production files is accessible using http://localhost:4200. This is not safe to use for production usage.For a production usage, you have to deploy all the files from the dist folder in the HTTP server of your choice. 这篇关于如何捆绑一个用于生产的 Angular 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-07 06:20