Sha256: a8f5512f9df224ddb5cbea3ab01b2ca23ed32f0c5407d3b62504511e9d32e21c

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 KB

Contents

const { resolve } = require('path')
const { safeLoad } = require('js-yaml')
const { readFileSync } = require('fs')
const deepMerge = require('./utils/deep_merge')
const { isArray } = require('./utils/helpers')
const { railsEnv } = require('./env')

const defaultConfigPath = require.resolve('../lib/install/config/webpacker.yml')
const configPath = resolve('config', 'webpacker.yml')

const getDefaultConfig = () => {
  const defaultConfig = safeLoad(readFileSync(defaultConfigPath), 'utf8')
  return defaultConfig[railsEnv] || defaultConfig.production
}

const defaults = getDefaultConfig()
const app = safeLoad(readFileSync(configPath), 'utf8')[railsEnv]

if (isArray(app.extensions) && app.extensions.length) delete defaults.extensions

const config = deepMerge(defaults, app)
config.outputPath = resolve('public', config.public_output_path)

let publicPath = `/${config.public_output_path}/`
// Add prefix to publicPath.
if (process.env.RAILS_RELATIVE_URL_ROOT) {
  publicPath = `/${process.env.RAILS_RELATIVE_URL_ROOT}${publicPath}`
}

// Remove extra slashes.
config.publicPath = publicPath.replace(/(^\/|[^:]\/)\/+/g, '$1')

module.exports = config

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
webpacker-3.6.0 package/config.js
optimacms-0.4.3 spec/dummy/node_modules/@rails/webpacker/package/config.js
optimacms-0.4.2 spec/dummy/node_modules/@rails/webpacker/package/config.js
webpacker-4.0.0.pre.3 package/config.js
webpacker-3.5.5 package/config.js
webpacker-3.5.3 package/config.js
webpacker-3.5.2 package/config.js
webpacker-3.5.1 package/config.js
webpacker-3.5.0 package/config.js