Skip to content

Instantly share code, notes, and snippets.

@dhilt
dhilt / .env
Last active April 8, 2022 17:36
How to set Angular CLI Development Server Port via .env
DEV_SERVER_PORT=4201
@dhilt
dhilt / package.json
Created May 4, 2020 04:16
Angular cli dev server port via .env // package.json
{
"name": "my-angular-project",
"scripts": {
"start": "node run-env"
},
"devDependencies": {
"dotenv": "^8.2.0"
}
}
@dhilt
dhilt / run-env.js
Created May 4, 2020 04:15
Angular cli dev server port via .env // node script
const dotenv = require('dotenv');
const child_process = require('child_process');
const config = dotenv.config()
const DEV_SERVER_PORT = process.env.DEV_SERVER_PORT || 4200;
const child = child_process.exec(`ng serve --port=${DEV_SERVER_PORT}`);
child.stderr.on('data', err => console.error(err));
child.stdout.on('data', data => console.log(data.toString()));
@dhilt
dhilt / .env
Last active May 4, 2020 04:17
Angular cli dev server port via .env // .env
DEV_SERVER_PORT=4201