Skip to content

Commit

Permalink
Resolve multi-word snakecase WEBPACKER_DEV_SERVER env values (#2528)
Browse files Browse the repository at this point in the history
Env values like WEBPACKER_DEV_SERVER_DISABLE_HOST_CHECK and
WEBPACKER_DEV_SERVER_USE_LOCAL_IP were not being read into the webpack
configuration because of the regex used to resolve the env var name.
  • Loading branch information
rossta committed Apr 11, 2020
1 parent 1e68429 commit 6f43982
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package/__tests__/dev_server.js
Expand Up @@ -13,11 +13,13 @@ describe('DevServer', () => {
process.env.RAILS_ENV = 'development'
process.env.WEBPACKER_DEV_SERVER_HOST = '0.0.0.0'
process.env.WEBPACKER_DEV_SERVER_PORT = 5000
process.env.WEBPACKER_DEV_SERVER_DISABLE_HOST_CHECK = false

const devServer = require('../dev_server')
expect(devServer).toBeDefined()
expect(devServer.host).toEqual('0.0.0.0')
expect(devServer.port).toEqual('5000')
expect(devServer.disable_host_check).toBe(false)
})

test('with custom env prefix', () => {
Expand Down
2 changes: 1 addition & 1 deletion package/dev_server.js
Expand Up @@ -12,7 +12,7 @@ if (devServerConfig) {
const envPrefix = config.dev_server.env_prefix || 'WEBPACKER_DEV_SERVER'

Object.keys(devServerConfig).forEach((key) => {
const envValue = fetch(`${envPrefix}_${key.toUpperCase().replace(/_/g, '')}`)
const envValue = fetch(`${envPrefix}_${key.toUpperCase()}`)
if (envValue !== undefined) devServerConfig[key] = envValue
})
}
Expand Down

0 comments on commit 6f43982

Please sign in to comment.