title: How to import file using dynamic path on Angular 6?
body: <p>I need to import file from path, which I get from variable's value. So it looks like this:</p>
  
  <pre><code>let test = require(configurationUrl);
  </code></pre>
  
  <p>where <code>configurationUrl</code> is some path like <code>'../../assets/app.conf.json'</code>.
  So when I run the app I get this error: </p>
  
  <blockquote>
    <p>core.js:1601 ERROR Error: Cannot find module "../../assets/app.conf.json".</p>
  </blockquote>
  
  <p>But when I write it like this:</p>
  
  <pre><code>let test = require("../../assets/app.conf.json");
  </code></pre>
  
  <p>there is no error.</p>
  
  <p>I have found this problem on <a href="https://github.com/angular/angular-cli/issues/3306" rel="nofollow noreferrer">Github</a>, but haven't find solution yet.</p>
  
  <p>Also I know that I can solve this issue like that:</p>
  
  <pre><code>loadConfigurationFromApi(configurationUrl: string) {
  
      this.http.get(configurationUrl).subscribe(
        res =&gt; {
          let test = res;
        })  
   }
  </code></pre>
  
  <p>But this way doesn't fit me.</p>