Typescript optional import only if exist
Asked Answered
T

0

6

I generate some git info in my Angular App with the npm package git-ref-sync to a file named ../environments/git-version.

In my component I import the generated stuff on this way:

import { gitVersion } from '../../environments/git-version';

But sometimes this file isn't yet generated, so is there a possibility to import this file only then if exists?

Tanker answered 20/8, 2020 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.