【问题标题】:Relative url paths in scss filesscss 文件中的相对 url 路径
【发布时间】:2020-01-15 11:57:26
【问题描述】:

我的 scss 文件中有一些相对 url 路径,例如:

&.id-1 {
    background-image: url("./assets/images/live-sports/icon-soccer.svg");
}

对于其他元素,我有这个 url 路径

&.id-1 {
    -webkit-mask-image: url("./assets/images/live-sports/terminal/icon-soccer.svg");
}

在我的 angular.json 中,该项目的构建选项如下所示:

"options": {
        "outputPath": "dist/AppLiveConference",
        "resourcesOutputPath": "resources",
        "index": "projects/AppLiveConference/src/index.html",
        "main": "projects/AppLiveConference/src/main.ts",
        "polyfills": "projects/AppLiveConference/src/polyfills.ts",
        "tsConfig": "projects/AppLiveConference/tsconfig.app.json",
        "aot": false,
        "assets": [
          "projects/AppLiveConference/src/favicon.ico",
          "projects/AppLiveConference/src/assets"
        ],
        "styles": [
          "projects/AppLiveConference/src/styles.scss"
        ],
        "scripts": [
          "node_modules/jquery/dist/jquery.min.js"
        ]
      }

问题是 angular-cli 忽略子文件夹并将所有资源文件放在资源文件夹中,并且“icon-soccer.svg”相互覆盖。我该如何解决这个问题?

angular-cli 版本:8.1.3

【问题讨论】:

    标签: node.js angular typescript angular-cli angular8


    【解决方案1】:

    你的网址是错误的,你应该删除它

    "options": {
            "outputPath": "dist/AppLiveConference",
            "resourcesOutputPath": "resources",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": false,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js"
            ]
          }
    

    【讨论】:

    • Index、main、polyfills 等路径都很好,项目已构建,但问题是我需要从 scss 文件中获取的所有资源(图像、字体)都在一个文件夹(资源)中,并且如果它们具有相同的名称,它们将相互覆盖......
    猜你喜欢
    • 1970-01-01
    • 2020-01-18
    • 2011-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-09
    • 2021-12-02
    • 1970-01-01
    相关资源
    最近更新 更多