Should `ng serve --prod` perform asset copy as in `ng build --prod`?

Viewed 169

I'm trying to understand the Angular build process that's executed when running ng serve --prod. I have configured asset copy (for assets from a project library) to happen during the build step. I expect this copy to also happen with ng serve, but it currently appears that I have to ng build before ng serve in order for asset copy to happen.

Here's the relevant bit of my angular.json file:

"architect": {
    "build": {
        "builder": "@angular-devkit/build-angular:browser",
        "options": {
            // ... 
            "assets": [
                "projects/app-name/src/favicon.ico",
                "projects/app-name/src/assets",
                {
                    "input": "projects/features/src/lib/",
                    "output": "/assets/",
                    "glob": "**-feature/assets/*"
                }
            ],
            // ... 
        },
    },
    "serve": {
        "builder": "@angular-devkit/build-angular:dev-server",
        "options": {
            "browserTarget": "app-name:build"
        },
        "configurations": {
            "production": {
                "browserTarget": "app-name:build:production"
            }
        }
    }
}

As I understand it, browserTarget": "app-name:build:production" is equivalent to ng build app-name --prod, so I expect the asset copy to happen, but it doesn't.

Any insight into this, or suggestions of how to achieve my preferred outcome, greatly appreciated.

0 Answers
Related