--aot:启用AOT(Ahead-of-Time)编译,将模板编译为可执行的JavaScript代码,以提高应用程序的性能和加载速度。 --base-href:指定应用程序的基本URL路径,用于在构建后的应用程序中正确加载资源文件。 --deploy-url:指定应用程序的部署URL路径,用于在构建后的应用程序中正确加载外部资源文件。 --vendor-chunk
"deployUrl": "/test/", } } } 或者ng build --deploy-url="/test/" ✨注意:deploy-url 只能修改被打包的资源文件。 样式资源引入 设置了 base-href 之后,样式文件中引入的资源路径的行为在各个 CLI 的版本下会有不同: 2~7 版本下会自动添加 base 路径。例如url("/assets/path/to/my/asset.png")...
"prefix": "app", // 使用`ng generate`命令时,自动为selector元数据的值添加的前缀名 "deployUrl": "//cdn.com.cn", // 指定站点的部署地址,该值最终会赋给webpack的output.publicPath,常用于CDN部署 "styles": [ // 引入全局样式,构建时会打包进来,常用于第三方库引入的样式 "styles.css" ], "scr...
在构建完成后,Angular CLI 会将所有打包生成的脚本文件插入到这个index.html中,生成类似于以下内容: <!doctype html><htmllang="en"><head><metacharset="utf-8"><title>Spartacus Store</title><basehref="/"><linkrel="stylesheet"href="styles.css"></head><body><app-root></app-root><scriptsrc="...
base-href可以设置服务器上的某个子路径,使用ng build --base-href=/my/path/ 如果打包静态文件(js和css)不放在和index.html同一路径下,可以在.angular-cli.json配置文件apps属性下增加deployUrl,等同于webpack的publicPath。 如遇刷新找不到页面(404)的情况,需要在服务器配置重定向到index.html。以nginx为例,可...
base-href可以设置服务器上的某个子路径,使用ng build --base-href=/my/path/ 如果打包静态文件(js和css)不放在和index.html同一路径下,可以在.angular-cli.json配置文件apps属性下增加deployUrl,等同于webpack的publicPath。 如遇刷新找不到页面(404)的情况,需要在服务器配置重定向到index.html。以nginx为例,可...
5.–base-href 指定站点的起始路径,如果你希望你的站点根路径为abc.com/mypath/,需要这样设置:ng build –base-href /mypath/ 6.–target 指定构建的目标,默认值是development,如果指定为production,构建时会加入treeshaking、代码压缩混淆等。下面两条等价: ng build –target=production ng build –prod 7.–...
--publicHost=publicHost Specify the URL that the browser client will use. --servePath=servePath The pathname where the app will be served. --servePathDefaultWarning=true|false Show a warning when deploy-url/base-href use unsupported serve path values. Default: true --sourceMap=true|false Out...
ng build --prod --deploy-url /demo/ --base-href /demo/ 1. 增加--deploy-url 和 --base-href。 使用场景:比如我们有多个站点,希望使用同一个反向代理, http://site1, http://site2, 分别映射到 http:///site1, ...
angular6以上不在需要去package.json里面配置一长串东西只需要"build:prod": "ng build --configuration=production",它会执行上面代码你配置的东西。有用 回复 冯恒智 7.9k2428 发布于 2018-11-14 ng build --prod --aot --base-href /项目名称/ng/ --deploy-url /项目名称/ng/ 有用 回复 葬...