import enviroment variables in js file in assets folder in Angular project

91 views Asked by At

I created a mobile-device.js file into assets/mobile folder in my Angular project, then I added the file path in the scripts array in angular.json file like this:

   "scripts": [
      "src/assets/mobile/mobile-device.js"
    ]

Now I need to import in this file (mobile-device.js) my environment variables adding this import statement on the top of the file:

import { environment } from '../../environments/environment';

but when I try to start my project I read in the browser console this error:

Cannot use import statement outside a module (at scripts.js:1:1)

I think the issue is something related to this -> How to use a js file by module type in angular any idea?

0

There are 0 answers