Last active
February 18, 2019 14:44
-
-
Save hawkeye64/4d389f6c9dd70e862a9c507512251ca9 to your computer and use it in GitHub Desktop.
dotenv App Extension index.js
This file contains hidden or 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
/** | |
* Quasar App Extension index/runner script | |
* (runs on each dev/build) | |
* | |
* API: https://github.com/quasarframework/quasar/blob/master/app/lib/app-extension/IndexAPI.js | |
*/ | |
const | |
fs = require('fs'), | |
path = require('path') | |
const envOptions = { | |
encoding: 'utf8', | |
envPath: process.cwd() | |
} | |
const extendWithDotenv = function (conf) { | |
const { config } = require('dotenv') | |
const parsed = config(envOptions).parsed | |
// make sure there is a build.env object | |
if (!conf.build.env) { | |
conf.build.env = {} | |
} | |
for (const key in parsed) { | |
conf.build.env[key] = JSON.stringify(parsed[key]) | |
} | |
} | |
module.exports = function (api, ctx) { | |
api.extendQuasarConf(extendWithDotenv) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment