mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
feat: automatically include env variables starting with NUXT_ENV_ (#3862)
This commit is contained in:
parent
f87992530e
commit
1e0219543a
@ -160,6 +160,10 @@ Options.from = function (_options) {
|
|||||||
vueConfig.performance = options.dev
|
vueConfig.performance = options.dev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// merge custom env with variables
|
||||||
|
const eligibleEnvVariables = _.pick(process.env, Object.keys(process.env).filter(k => k.startsWith('NUXT_ENV_')))
|
||||||
|
Object.assign(options.env, eligibleEnvVariables)
|
||||||
|
|
||||||
// Normalize ignore
|
// Normalize ignore
|
||||||
options.ignore = options.ignore ? [].concat(options.ignore) : []
|
options.ignore = options.ignore ? [].concat(options.ignore) : []
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { buildFixture } from '../../utils/build'
|
import { buildFixture } from '../../utils/build'
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
process.env.NUXT_ENV_FOO = 'manniL'
|
||||||
|
})
|
||||||
|
|
||||||
let customCompressionMiddlewareFunctionName
|
let customCompressionMiddlewareFunctionName
|
||||||
const hooks = [
|
const hooks = [
|
||||||
['render:errorMiddleware', (app) => {
|
['render:errorMiddleware', (app) => {
|
||||||
@ -20,3 +24,7 @@ describe('with-config', () => {
|
|||||||
expect(customCompressionMiddlewareFunctionName).toBe('damn')
|
expect(customCompressionMiddlewareFunctionName).toBe('damn')
|
||||||
}, hooks)
|
}, hooks)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
delete process.env.NUXT_ENV_FOO
|
||||||
|
})
|
||||||
|
@ -92,6 +92,7 @@ describe('with-config', () => {
|
|||||||
expect(html.includes('"string": "ok"')).toBe(true)
|
expect(html.includes('"string": "ok"')).toBe(true)
|
||||||
expect(html.includes('"num2": 8.23')).toBe(true)
|
expect(html.includes('"num2": 8.23')).toBe(true)
|
||||||
expect(html.includes('"obj": {')).toBe(true)
|
expect(html.includes('"obj": {')).toBe(true)
|
||||||
|
expect(html).toContain('"NUXT_ENV_FOO": "manniL"')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/test/error', async () => {
|
test('/test/error', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user