Skip to content

Commit 9f4609d

Browse files
authored
feat(backport): support environments (#203)
Co-authored-by: lihbr <lihbr@users.noreply.github.com>
1 parent 2ab5084 commit 9f4609d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ node_modules
77
.DS_Store
88
coverage
99
dist
10+
.env

src/module.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ function install (moduleOptions) {
2222
logger.warn('Options `endpoint` is required, disabling module...')
2323
return
2424
}
25+
if (process.env.NUXT_PUBLIC_PRISMIC_ENVIRONMENT) {
26+
options.endpoint = process.env.NUXT_PUBLIC_PRISMIC_ENVIRONMENT
27+
try {
28+
// eslint-disable-next-line no-new
29+
new URL(options.endpoint)
30+
} catch (error) {
31+
options.endpoint = `https://${options.endpoint}.cdn.prismic.io/api/v2`
32+
}
33+
}
2534

2635
this.options.build.transpile.push('@prismicio/vue', '@prismicio/simulator')
2736

0 commit comments

Comments
 (0)