0

在我的项目构建配置中,我有以下资产声明:

"assets": [ "src/favicon.ico", "src/assets", "src/assets/fonts", "src/images", "src/web.config" ],

然后在我的部署配置中:

"deploy": { "assets": [ {"glob": "config.json", "input": "src/environments/", "output": "/"}],

使用“部署”配置构建时,不再部署上面声明的资产。只有 config.json 文件被部署。

我必须将这些资产添加到“部署”中的资产数组中作为解决方法。这是正确的方法吗?或者有没有办法避免覆盖资产构建声明?

4

1 回答 1

0

我不知道你为什么要配置特定的部署,它已经配置在 中angular.json,你可以在这个文件中添加一个新的配置,就像提供的运行它的例子一样, ng build --c=build或者使用 ng build --c=stagingwhere c stand to configuration运行第二个confiduration

顺便说一下,你应该得到包含资产文件的 dist 文件夹

  "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/AngularProject",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.app.json",
        "assets": [
          "src/favicon.ico",
          "src/assets",
          "src/web.config",
          "src/WEB-INF"
        ],
        "styles": [
          "src/styles.scss",
          "src/assets/css/fontawesome-all.min.css",
          "src/assets/css/themify-icons.css"
        ],
        "stylePreprocessorOptions": {
          "includePaths": [
          ]
      },
        "scripts": [
          "./node_modules/jquery/dist/jquery.js",
          "./node_modules/popper.js/dist/umd/popper.min.js",
          "./node_modules/bootstrap/dist/js/bootstrap.js",
          "./node_modules/jspdf/dist/jspdf.min.js",
          "./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
        ]
      },
      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true,
          "budgets": [
            {
              "type": "initial",
              "maximumWarning": "4mb",
              "maximumError": "5mb"
            }
          ]
        },
        "staging": {   // a new configuration 
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.staging.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true,
          "budgets": [
            {
              "type": "initial",
              "maximumWarning": "4mb",
              "maximumError": "5mb"
            }
          ]
        }
      }
    },

ng build要部署,使用所需的配置运行就足够了

我不确定我是否知道你的问题是什么

于 2019-03-26T09:32:59.273 回答