用于cli服务和ng构建的cli配置中的不同资产[Angular 5] [英] Different assets in cli config for ng serve and ng build [Angular 5]

查看:109
本文介绍了用于cli服务和ng构建的cli配置中的不同资产[Angular 5]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ng build时可以使用其他资产数组吗?

Is possible to use different assets array when i use ng build?

"assets": [
  "assets",
  "favicon.ico",
  {
    "glob": "**/*",
    "input": "../externalDir",
    "output": "./app/",
    "allowOutsideOutDir": true
  }
]

在我使用ng build的情况下,我只想构建:

In my case when i use ng build i want to build only this:

"assets": [
  "assets",
  "favicon.ico"
]

推荐答案

我不认为可以选择特定于环境的资产.但是您可以在angular-cli.json中制作其他应用,这些应用基本上只是彼此的副本,但是资源不同.例如

I don't believe there is an option to do environment specific assets. But you can make additional apps in your angular-cli.json which are basically just copies of each other, but with different assets. For example

// angular-cli.json
"apps": [
    {
        "root": "src",
        "outDir": "dist",
        "name": "devApp",
        "assets" : [
            "assets",
            "favicon.ico",
            {
                "glob": "**/*",
                "input": "../externalDir",
                "output": "./app/",
                "allowOutsideOutDir": true
            },
        ],
        ...
    },
    {
        "root": "src",
        "outDir": "dist",
        "name": "prodApp",
        "assets": [
            "assets",
            "favicon.ico"
        ],
        ...
    }
]

现在,您可以通过构建特定的应用"来不同地构建资产

Now you can build your assets differently by building a specific "app"

// dev
ng build --app=0
// or
ng build --app=devApp

// prod
ng build --app=1
// or
ng build --app=prodApp

Angular cli 文档在多个应用上.

Angular cli docs on multiple apps.

这篇关于用于cli服务和ng构建的cli配置中的不同资产[Angular 5]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆