【问题标题】:angular 11 custom accessible assets folderangular 11 自定义可访问资产文件夹
【发布时间】:2021-08-07 11:13:06
【问题描述】:

我正在使用 Angular 11,通过此配置,我可以设置自定义可访问资产文件夹,它可以在本地工作,但是当我使用“ng build --prod”构建项目并将其上传到服务器时,该文件夹似乎是无法访问。

"build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/Linkeee",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "tsconfig.app.json",
        "aot": true,
        "assets": [
          "src/favicon.ico",
          "src/manifest.webmanifest",
          {"glob": "**/*", "input": "D:/images", "output": "./assets/"}
          
          
        ],
        "styles": [
          "node_modules/bootstrap/dist/css/bootstrap.min.css",
          "node_modules/ngx-toastr/toastr.css",
          "src/custom-theme.scss",
          "src/styles.css"
          
        ],
        "scripts": [
          "node_modules/apexcharts/dist/apexcharts.min.js"
        ]
      },

我将“D:/images”定义为“资产”。 有什么想法吗?

【问题讨论】:

    标签: angular


    【解决方案1】:

    没有这样的方法。您的 Angular 应用程序从目录“angular.json”文件开始。您只能在 development 环境中使用本地计算机上的任何文件。这些路径在production 环境中将无效。最好的方法是将 'D:\images' 中包含的文件移动到 'src/images' 或 src/assets/images 并更改

    "assets": [
              "src/favicon.ico",
              "src/manifest.webmanifest",
              {"glob": "**/*", "input": "src/images/**", "output": "./assets/"}
              
              
            ],
    

    【讨论】:

    • 谢谢,但我有一个问题,我想在其他目录中显示由其他应用程序上传的图像。我该怎么办?
    猜你喜欢
    • 2013-06-20
    • 2017-12-11
    • 2017-06-14
    • 2020-12-10
    • 1970-01-01
    • 1970-01-01
    • 2018-02-13
    • 1970-01-01
    • 2012-05-13
    相关资源
    最近更新 更多