Sha256: 89d4835ce1856ed17688459f382cfad72765625b04a72639e6f632b96e856dc5

Contents?: true

Size: 672 Bytes

Versions: 11

Compression:

Stored size: 672 Bytes

Contents

const { resolve } = require('path')
const { safeLoad } = require('js-yaml')
const { readFileSync } = require('fs')

const NODE_ENVIRONMENTS = ['development', 'production']
const DEFAULT = 'production'
const configPath = resolve('config', 'webpacker.yml')

const railsEnv = process.env.RAILS_ENV
const nodeEnv = process.env.NODE_ENV

const config = safeLoad(readFileSync(configPath), 'utf8')
const availableEnvironments = Object.keys(config).join('|')
const regex = new RegExp(availableEnvironments, 'g')

module.exports = {
  railsEnv: railsEnv && railsEnv.match(regex) ? railsEnv : DEFAULT,
  nodeEnv: nodeEnv && NODE_ENVIRONMENTS.includes(nodeEnv) ? nodeEnv : DEFAULT
}

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
optimacms-0.4.3 spec/dummy/node_modules/@rails/webpacker/package/env.js
optimacms-0.4.2 spec/dummy/node_modules/@rails/webpacker/package/env.js
webpacker-3.5.3 package/env.js
webpacker-3.5.2 package/env.js
webpacker-3.5.1 package/env.js
webpacker-3.5.0 package/env.js
webpacker-3.4.3 package/env.js
webpacker-4.0.0.pre.pre.2 package/env.js
webpacker-4.0.0.pre.pre.1 package/env.js
webpacker-3.4.1 package/env.js
webpacker-3.4.0 package/env.js