You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Angular CLI 1.7.2的.angular-cli.json转换为6.x的angular.json格式?

嘿,我来帮你把Angular CLI 1.7.2的配置转换成6.x版本的angular.json格式,其实非常直观,核心就是调整配置项的结构,同时保留原有的路径即可:

转换后的完整配置片段

在你的angular.json文件中,找到对应项目的build配置下的options部分,替换成以下内容:

"styles": [
  { "input": "../scss/bootstrap/bootstrap.scss" },
  { "input": "../src/assets/styles/icon8.css" },
  { "input": "styles.scss" },
  { "input": "styles-props.css" }
],
"scripts": [
  { "input": "../node_modules/web-animations-js/web-animations.min.js" },
  { "input": "../node_modules/jquery/dist/jquery.js" }
]

额外说明

  1. 格式灵活性:Angular 6+的styles和scripts数组支持两种写法:
    • 上面用的是对象格式,适合后续需要添加bundleName、lazy等高级配置的场景;
    • 如果不需要额外配置,也可以简化成更简洁的字符串数组形式:
      "styles": [
        "../scss/bootstrap/bootstrap.scss",
        "../src/assets/styles/icon8.css",
        "styles.scss",
        "styles-props.css"
      ],
      "scripts": [
        "../node_modules/web-animations-js/web-animations.min.js",
        "../node_modules/jquery/dist/jquery.js"
      ]
      
  2. 路径兼容性:你原有的相对路径不需要修改,因为angular.json和旧版的.angular-cli.json一样位于项目根目录,路径的相对指向逻辑完全一致。

内容的提问来源于stack exchange,提问作者st_clair_clarke

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:24:01