Skip to content

Instantly share code, notes, and snippets.

@hawkeye64
Last active February 18, 2019 14:44
Show Gist options
  • Save hawkeye64/4d389f6c9dd70e862a9c507512251ca9 to your computer and use it in GitHub Desktop.
Save hawkeye64/4d389f6c9dd70e862a9c507512251ca9 to your computer and use it in GitHub Desktop.
dotenv App Extension index.js
/**
 * 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