Sha256: f25ad9b96ade87c37fe7c3c62c7cf5ea29ae0d62b38df1b9898c5745c6b89706
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
const { resolve } = require('path') const { load } = require('js-yaml') const { existsSync, readFileSync } = require('fs') const { merge } = require('webpack-merge') const { ensureTrailingSlash, setShakapackerEnvVariablesForBackwardCompatibility } = require('./utils/helpers') const { railsEnv } = require('./env') const configPath = require('./utils/configPath') const defaultConfigPath = require('./utils/defaultConfigPath') const getDefaultConfig = () => { const defaultConfig = load(readFileSync(defaultConfigPath), 'utf8') return defaultConfig[railsEnv] || defaultConfig.production } const defaults = getDefaultConfig() let config if (existsSync(configPath)) { const appYmlObject = load(readFileSync(configPath), 'utf8') const envAppConfig = appYmlObject[railsEnv] if (!envAppConfig) { /* eslint no-console:0 */ console.warn(`Warning: ${railsEnv} key not found in the configuration file. Using production configuration as a fallback.`) } config = merge(defaults, envAppConfig || {}) } else { config = merge(defaults, {}) } 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 = () => { setShakapackerEnvVariablesForBackwardCompatibility() const rootUrl = ensureTrailingSlash(process.env.SHAKAPACKER_ASSET_HOST || '/') return `${rootUrl}${config.public_output_path}/` } config.publicPath = getPublicPath() config.publicPathWithoutCDN = `/${config.public_output_path}/` if (config.manifest_path) { config.manifestPath = resolve(config.manifest_path) } else { config.manifestPath = resolve(config.outputPath, 'manifest.json') } config.includePaths = [config.source_path, ...config.additional_paths] module.exports = config
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shakapacker-7.3.0.beta.1 | package/config.js |