I have some assets (images, styles) which I only need during development (ng serve). These assets must not be included in the production build. In production these assets are provided by a CDN.
I need:
but:
I have worked through 10 similar questions here on SO and 5 issues on github, they all deal with excluding files, but none solved my situation.
If you require assets for your tools, like images or models, create a resource inside your Editor folder to exclude the assets from any builds you make. You can get a similar effect by using assembly definitions. To do that, create a folder with the scripts you want to exclude and create an assembly definition asset inside.
This will make any build and serve with the production flag to exclude the assets. If you really want all the builds, no matter the environment, to build without assets, you move the assets array from projects. {project-name}.architect.build.options to the projects. {project-name}.architect.serve.options and set the one in build to an empty array.
You can get a similar effect by using assembly definitions. To do that, create a folder with the scripts you want to exclude and create an assembly definition asset inside. On the inspector in the included platforms section, only select Editor. This way, builds won't include the scripts.
Inside your angular.json there is a configurations object projects. {project-name}.architect.build.configurations. This is untested though, but by judging from what I know from the configuration file, this should be possible. This will make any build and serve with the production flag to exclude the assets.
Inside your angular.json
there is a configurations object projects.{project-name}.architect.build.configurations
.
Set the assets
inside the prod entry to []
"production": {
//...
"assets": []
}
This is untested though, but by judging from what I know from the configuration file, this should be possible.
This will make any build and serve with the production flag to exclude the assets. If you really want all the builds, no matter the environment, to build without assets, you move the assets
array from projects.{project-name}.architect.build.options
to the projects.{project-name}.architect.serve.options
and set the one in build
to an empty array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With