Skip to content

Commit

Permalink
Merge pull request #155 from yusufkandemir/fix-154-graphql-package-pr…
Browse files Browse the repository at this point in the history
…ocess.env-issue

fix: make graphql package work with Vite (fix: #154)
  • Loading branch information
smolinari authored Jan 14, 2024
2 parents 6392c00 + a9e1865 commit a813818
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
* @param {import('@quasar/app-vite').IndexAPI} api
*/
module.exports = function (api) {
api.extendQuasarConf((conf) => {
api.extendQuasarConf((conf, api) => {
// Allow overriding the graphql uri using an env variable
// https://quasar.dev/quasar-cli/handling-process-env#Adding-to-process.env
conf.build.env.GRAPHQL_URI = process.env.GRAPHQL_URI
if (api.prompts.subscriptions === true) {
conf.build.env.GRAPHQL_URI_WS = process.env.GRAPHQL_URI_WS
}

// `graphql` package does not work with Vite, so apply a workaround
// See: https://github.com/quasarframework/app-extension-apollo/issues/154
if (api.hasVite) {
conf.build.rawDefine = {
...conf.build.rawDefine,
'globalThis.process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
}
})
}

0 comments on commit a813818

Please sign in to comment.