如何将 src 文件夹构建到不同的构建文件夹而不覆盖构建文件夹的资源

问题描述 投票:0回答:1

在我们的本地服务器中,我们有一个“产品”文件夹,我们的 nginx 从中运行我们的前端。 该产品文件夹包含我们的源文件夹之一的构建。 由于我们构建时的这种委托 - 我们的源文件夹中的资产文件夹会被覆盖 我们的产品文件夹中的资产文件夹。这是不可接受的,因为我们的资产可以由我们的用户更改,例如:我们的用户可以从管理面板编辑 i18n 翻译。

1)。我们尝试像这样更改 angular.json:

          "configurations": {
            "dev": {
            "assets" : []

脚本

ng build  --configuration dev --optimization=false --output-path=E:\path\nginx-1.17.4\html\product

结果是,构建资产文件夹后,不会被覆盖而忽略。

2)。然后我们尝试将产品资产路径放在括号中:

      "configurations": {
        "dev": {
          "assets": ["../../../product/assets"]

脚本

ng build  --configuration dev --optimization=false --output-path=E:\path\nginx-1.17.4\html\product

仅收到以下错误:

An unhandled exception occurred: The ../../../product/assets asset path must start with the project source root.

3)。然后根据 this github thread 我们尝试了:

  "configurations": {
    "dev": {
      "assets": [{"glob": "**/favicon.png", "input" : "E:/path/nginx-1.17.4/html/product/assets", "output": "assets"}],

相同的脚本。

结果 - 构建后资产文件夹不存在。

有没有办法在构建到与源路径不同的路径时不覆盖资产文件夹?

规格

Angular 13.2.3
Node 14.15.1
OS win32 x64
json angular nginx build assets
1个回答
0
投票

使用 Angular CLI 构建选项

--delete-output-path=false
Angular CLI 构建选项

© www.soinside.com 2019 - 2024. All rights reserved.