-
-
Save marcosborges/33c1b5db066e09cd450ca345372c601f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL_API=http://www.minhaapi.com.br/meu-endpoint | |
TOKEN_NAME=access_token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const dotenv = require('dotenv'); | |
dotenv.config(); | |
const targetPath = `./src/environments/environment.ts`; | |
const envConfigFile = ` | |
export const environment = { | |
url_api: "${process.env.URL_API}", | |
token_name: "${process.env.TOKEN_NAME}" | |
}; | |
` | |
fs.writeFile(targetPath, envConfigFile, function (err) { | |
if (err) { | |
console.log(err); | |
} | |
console.log(`Output generated at ${targetPath}`); | |
}); | |
//ts-node set-env.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"ng": "ng", | |
"config": "ts-node ./scripts/angular_set_environtment.ts", | |
"start": "npm run config && ng serve", | |
"build": "npm run config && ng build", | |
"test": "ng test", | |
"lint": "ng lint", | |
"e2e": "ng e2e" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment