diff --git a/app/js/main.es6.js b/app/js/main.es6.js index 86e96301..419db2bc 100644 --- a/app/js/main.es6.js +++ b/app/js/main.es6.js @@ -10,8 +10,8 @@ import { onkeydowndocument, onkeydowninput } from './onkeydown.es6' const config = { app: 'webapp', - server_host: 'localhost', - server_port: 1337, + server_host: process.env.LEON_SERVER_HOST, + server_port: process.env.LEON_SERVER_PORT, min_decibels: -40, // Noise detection sensitivity max_blank_time: 1000 // Maximum time to consider a blank (ms) } diff --git a/package-lock.json b/package-lock.json index 2f9080ce..4c7fd0f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3898,6 +3898,16 @@ "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=" }, + "envify": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/envify/-/envify-4.1.0.tgz", + "integrity": "sha512-IKRVVoAYr4pIx4yIWNsz9mOsboxlNXiu7TNBnem/K/uTHdkyzXWDzHCK7UTolqBbgaBz0tQHsD3YNls0uIIjiw==", + "dev": true, + "requires": { + "esprima": "^4.0.0", + "through": "~2.3.4" + } + }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", diff --git a/package.json b/package.json index adf5a90f..4f291c19 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "browserify": "^14.4.0", "cli-spinner": "^0.2.8", "dev-ip": "^1.0.1", + "envify": "^4.1.0", "eslint": "^3.19.0", "eslint-config-airbnb-base": "^11.2.0", "eslint-import-resolver-babel-module": "^4.0.0", diff --git a/scripts/app/build-app.js b/scripts/app/build-app.js index 7e6d0e84..86e8aafd 100644 --- a/scripts/app/build-app.js +++ b/scripts/app/build-app.js @@ -1,5 +1,7 @@ import fs from 'fs' import browserify from 'browserify' +import envify from 'envify/custom' +import dotenv from 'dotenv' import log from '@/helpers/log' @@ -7,8 +9,11 @@ import log from '@/helpers/log' * Build web app */ export default () => new Promise((resolve) => { + // read .env file from leon root directory + dotenv.config() browserify('app/js/main.es6.js') .transform('babelify') + .transform(envify(process.env)) .bundle() .on('error', err => log.error(`[${err.name}] ${err.message}`)) .pipe(fs.createWriteStream('app/js/main.js'))