Sha256: d566df348b77514f7a2d3037d9080cd2f91307f9260680d291b9c323f383b0e6

Contents?: true

Size: 1.43 KB

Versions: 17

Compression:

Stored size: 1.43 KB

Contents

const { resolve } = require('path')
const { safeLoad } = require('js-yaml')
const { readFileSync } = require('fs')
const deepMerge = require('./utils/deep_merge')
const { isArray, ensureTrailingSlash } = 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
if (isArray(app.static_assets_extensions) && app.static_assets_extensions.length) {
  delete defaults.static_assets_extensions
}

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

// Ensure that the publicPath includes our asset host so dynamic imports
// (code-splitting chunks and static assets) load from the CDN instead of a relative path.
const getPublicPath = () => {
  const rootUrl = ensureTrailingSlash(process.env.WEBPACKER_ASSET_HOST || '/')
  return `${rootUrl}${config.public_output_path}/`
}

config.publicPath = getPublicPath()
config.publicPathWithoutCDN = `/${config.public_output_path}/`

module.exports = config

Version data entries

17 entries across 17 versions & 5 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/@rails/webpacker/package/config.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/@rails/webpacker/package/config.js
webpacker-4.3.0 package/config.js
enju_library-0.3.8 spec/dummy/node_modules/@rails/webpacker/package/config.js
webpacker-5.1.1 package/config.js
webpacker-5.1.0 package/config.js
webpacker-5.0.1 package/config.js
webpacker-5.0.0 package/config.js
jetpacker-0.4.2 package/config.js
jetpacker-0.4.1 package/config.js
jetpacker-0.4.0 package/config.js
jetpacker-0.3.0 package/config.js
jetpacker-0.2.0 package/config.js
webpacker-4.2.2 package/config.js
webpacker-4.2.1 package/config.js
webpacker-4.2.0 package/config.js
webpacker-4.1.0 package/config.js