Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RAILS_RELATIVE_URL_ROOT from publicPath #2151

Merged
merged 2 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions package/__tests__/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,6 @@ describe('Config', () => {
expect(config.publicPath).toEqual('/packs/')
})

// also tests removal of extra slashes
test('public path with relative root', () => {
process.env.RAILS_ENV = 'development'
process.env.RAILS_RELATIVE_URL_ROOT = '/foo'
const config = require('../config')
expect(config.publicPath).toEqual('/foo/packs/')
})

test('public path with relative root without slash', () => {
process.env.RAILS_ENV = 'development'
process.env.RAILS_RELATIVE_URL_ROOT = 'foo'
const config = require('../config')
expect(config.publicPath).toEqual('/foo/packs/')
})

test('public path with asset host and relative root', () => {
process.env.RAILS_ENV = 'development'
process.env.RAILS_RELATIVE_URL_ROOT = '/foo/'
process.env.WEBPACKER_ASSET_HOST = 'http://foo.com/'
const config = require('../config')
expect(config.publicPath).toEqual('http://foo.com/foo/packs/')
})

test('public path with asset host', () => {
process.env.RAILS_ENV = 'development'
process.env.WEBPACKER_ASSET_HOST = 'http://foo.com/'
Expand Down
9 changes: 1 addition & 8 deletions package/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@ config.outputPath = resolve(config.public_root_path, config.public_output_path)
// (code-splitting chunks and static assets) load from the CDN instead of a relative path.
const getPublicPath = () => {
const rootUrl = process.env.WEBPACKER_ASSET_HOST || '/'
let packPath = `${config.public_output_path}/`
// Add relative root prefix to pack path.
if (process.env.RAILS_RELATIVE_URL_ROOT) {
let relativeRoot = process.env.RAILS_RELATIVE_URL_ROOT
relativeRoot = relativeRoot.startsWith('/') ? relativeRoot.substr(1) : relativeRoot
packPath = `${ensureTrailingSlash(relativeRoot)}${packPath}`
}

const packPath = `${config.public_output_path}/`
return ensureTrailingSlash(rootUrl) + packPath
sspread marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down